mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
This commit is contained in:
parent
a9619ab9ce
commit
8bfd1a23a1
2 changed files with 14 additions and 5 deletions
|
|
@ -3,13 +3,17 @@ use std::sync::{Arc, atomic::{AtomicUsize, Ordering::Relaxed}};
|
|||
|
||||
pub trait HasSize<E: Output> {
|
||||
fn size (&self) -> &Measure<E>;
|
||||
fn width (&self) -> usize {
|
||||
self.size().w()
|
||||
}
|
||||
fn height (&self) -> usize {
|
||||
self.size().w()
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! has_size {
|
||||
(<$E:ty>|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
impl $(<$($L),*$($T $(: $U)?),*>)? HasSize<$E> for $Struct $(<$($L),*$($T),*>)? {
|
||||
fn size (&$self) -> &Measure<$E> { $cb }
|
||||
}
|
||||
impl<E: Output, T: Has<Measure<E>>> HasSize<E> for T {
|
||||
fn size (&self) -> &Measure<E> {
|
||||
self.get()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue