pub struct Size<T> {
pub width: T,
pub height: T,
}Expand description
The width and height of a Rect
Fields§
§width: TThe x extent of the rectangle
height: TThe y extent of the rectangle
Implementations§
Source§impl<T> Size<T>
impl<T> Size<T>
Sourcepub fn get_abs(self, axis: AbsoluteAxis) -> T
pub fn get_abs(self, axis: AbsoluteAxis) -> T
Get either the width or height depending on the AbsoluteAxis passed in
Source§impl<T> Size<T>
impl<T> Size<T>
Sourcepub fn map<R, F>(self, f: F) -> Size<R>where
F: Fn(T) -> R,
pub fn map<R, F>(self, f: F) -> Size<R>where
F: Fn(T) -> R,
Applies the function f to both the width and height
This is used to transform a Size<T> into a Size<R>.
Sourcepub fn map_width<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
pub fn map_width<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
Applies the function f to the width
Sourcepub fn map_height<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
pub fn map_height<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
Applies the function f to the height
Source§impl Size<f32>
impl Size<f32>
Sourcepub fn has_non_zero_area(self) -> bool
pub fn has_non_zero_area(self) -> bool
Return true if both width and height are greater than 0 else false
Source§impl Size<Option<f32>>
impl Size<Option<f32>>
Sourcepub const fn new(width: f32, height: f32) -> Size<Option<f32>>
pub const fn new(width: f32, height: f32) -> Size<Option<f32>>
A Size<Option<f32>> with Some(width) and Some(height) as parameters
Sourcepub const fn from_cross(
direction: FlexDirection,
value: Option<f32>,
) -> Size<Option<f32>>
pub const fn from_cross( direction: FlexDirection, value: Option<f32>, ) -> Size<Option<f32>>
Creates a new Size<Option<f32>> with either the width or height set based on the provided direction
Sourcepub fn maybe_apply_aspect_ratio(
self,
aspect_ratio: Option<f32>,
) -> Size<Option<f32>>
pub fn maybe_apply_aspect_ratio( self, aspect_ratio: Option<f32>, ) -> Size<Option<f32>>
Applies aspect_ratio (if one is supplied) to the Size:
- If width is
Somebut height isNone, then height is computed from width and aspect_ratio - If height is
Somebut width isNone, then width is computed from height and aspect_ratio
If aspect_ratio is None then this function simply returns self.
Source§impl<T> Size<Option<T>>
impl<T> Size<Option<T>>
Sourcepub fn unwrap_or(self, alt: Size<T>) -> Size<T>
pub fn unwrap_or(self, alt: Size<T>) -> Size<T>
Performs Option::unwrap_or on each component separately
Sourcepub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>
pub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>
Performs Option::or on each component separately
Sourcepub fn both_axis_defined(&self) -> bool
pub fn both_axis_defined(&self) -> bool
Return true if both components are Some, else false.
Source§impl Size<Dimension>
impl Size<Dimension>
Sourcepub const fn from_lengths(width: f32, height: f32) -> Size<Dimension>
pub const fn from_lengths(width: f32, height: f32) -> Size<Dimension>
Generates a Size<Dimension> using length values
Sourcepub const fn from_percent(width: f32, height: f32) -> Size<Dimension>
pub const fn from_percent(width: f32, height: f32) -> Size<Dimension>
Generates a Size<Dimension> using percentage values
Source§impl Size<AvailableSpace>
impl Size<AvailableSpace>
Source§impl<T> Size<T>where
T: TaffyMinContent,
impl<T> Size<T>where
T: TaffyMinContent,
Sourcepub const fn min_content() -> Size<T>
pub const fn min_content() -> Size<T>
Returns a Size where both the width and height values are the min_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T> Size<T>where
T: TaffyMaxContent,
impl<T> Size<T>where
T: TaffyMaxContent,
Sourcepub const fn max_content() -> Size<T>
pub const fn max_content() -> Size<T>
Returns a Size where both the width and height values are the max_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T> Size<T>where
T: TaffyFitContent,
impl<T> Size<T>where
T: TaffyFitContent,
Sourcepub fn fit_content(argument: LengthPercentage) -> Size<T>
pub fn fit_content(argument: LengthPercentage) -> Size<T>
Returns a Size where with width and height set to the same fit-content(…) value
with the given argument.
Source§impl<T> Size<T>where
T: FromLength,
impl<T> Size<T>where
T: FromLength,
Trait Implementations§
Source§impl<T> FromLength for Size<T>where
T: FromLength,
impl<T> FromLength for Size<T>where
T: FromLength,
Source§impl<T> FromPercent for Size<T>where
T: FromPercent,
impl<T> FromPercent for Size<T>where
T: FromPercent,
Source§impl<In, Out, T> MaybeMath<Size<In>, Size<Out>> for Size<T>where
T: MaybeMath<In, Out>,
impl<In, Out, T> MaybeMath<Size<In>, Size<Out>> for Size<T>where
T: MaybeMath<In, Out>,
Source§impl<In, Out, T> MaybeResolve<Size<In>, Size<Out>> for Size<T>where
T: MaybeResolve<In, Out>,
impl<In, Out, T> MaybeResolve<Size<In>, Size<Out>> for Size<T>where
T: MaybeResolve<In, Out>,
Source§impl<In, Out, T> ResolveOrZero<Size<In>, Size<Out>> for Size<T>where
Out: TaffyZero,
T: ResolveOrZero<In, Out>,
impl<In, Out, T> ResolveOrZero<Size<In>, Size<Out>> for Size<T>where
Out: TaffyZero,
T: ResolveOrZero<In, Out>,
Source§impl<T> TaffyFitContent for Size<T>where
T: TaffyFitContent,
impl<T> TaffyFitContent for Size<T>where
T: TaffyFitContent,
Source§fn fit_content(argument: LengthPercentage) -> Size<T>
fn fit_content(argument: LengthPercentage) -> Size<T>
Source§impl<T> TaffyMaxContent for Size<T>where
T: TaffyMaxContent,
impl<T> TaffyMaxContent for Size<T>where
T: TaffyMaxContent,
Source§const MAX_CONTENT: Size<T>
const MAX_CONTENT: Size<T>
Source§impl<T> TaffyMinContent for Size<T>where
T: TaffyMinContent,
impl<T> TaffyMinContent for Size<T>where
T: TaffyMinContent,
Source§const MIN_CONTENT: Size<T>
const MIN_CONTENT: Size<T>
impl<T> Copy for Size<T>where
T: Copy,
impl<T> Eq for Size<T>where
T: Eq,
impl<T> StructuralPartialEq for Size<T>
Auto Trait Implementations§
impl<T> Freeze for Size<T>where
T: Freeze,
impl<T> RefUnwindSafe for Size<T>where
T: RefUnwindSafe,
impl<T> Send for Size<T>where
T: Send,
impl<T> Sync for Size<T>where
T: Sync,
impl<T> Unpin for Size<T>where
T: Unpin,
impl<T> UnsafeUnpin for Size<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Size<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().