Struct lay_rs::prelude::taffy::Size

pub struct Size<T> {
    pub width: T,
    pub height: T,
}
Expand description

The width and height of a Rect

Fields§

§width: T

The x extent of the rectangle

§height: T

The y extent of the rectangle

Implementations§

§

impl<T> Size<T>

pub fn get_abs(self, axis: AbsoluteAxis) -> T

Get either the width or height depending on the AbsoluteAxis passed in

§

impl<T> Size<T>

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>.

pub fn map_width<F>(self, f: F) -> Size<T>
where F: Fn(T) -> T,

Applies the function f to the width

pub fn map_height<F>(self, f: F) -> Size<T>
where F: Fn(T) -> T,

Applies the function f to the height

pub fn zip_map<Other, Ret, Func>(self, other: Size<Other>, f: Func) -> Size<Ret>
where Func: Fn(T, Other) -> Ret,

Applies the function f to both the width and height of this value and another passed value

§

impl Size<f32>

pub const ZERO: Size<f32> = _

A Size with zero width and height

pub fn f32_max(self, rhs: Size<f32>) -> Size<f32>

Applies f32_max to each component separately

pub fn f32_min(self, rhs: Size<f32>) -> Size<f32>

Applies f32_min to each component separately

pub fn has_non_zero_area(self) -> bool

Return true if both width and height are greater than 0 else false

§

impl Size<Option<f32>>

pub const NONE: Size<Option<f32>> = _

A Size with None width and height

pub const fn new(width: f32, height: f32) -> Size<Option<f32>>

A Size<Option<f32>> with Some(width) and Some(height) as parameters

pub 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

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 Some but height is None, then height is computed from width and aspect_ratio
  • If height is Some but width is None, then width is computed from height and aspect_ratio

If aspect_ratio is None then this function simply returns self.

§

impl<T> Size<Option<T>>

pub fn unwrap_or(self, alt: Size<T>) -> Size<T>

Performs Option::unwrap_or on each component separately

pub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>

Performs Option::or on each component separately

pub fn both_axis_defined(&self) -> bool

Return true if both components are Some, else false.

§

impl Size<Dimension>

pub const fn from_lengths(width: f32, height: f32) -> Size<Dimension>

Generates a Size<Dimension> using Dimension::Length values

pub const fn from_percent(width: f32, height: f32) -> Size<Dimension>

Generates a Size<Dimension> using Dimension::Percent values

§

impl Size<AvailableSpace>

pub fn into_options(self) -> Size<Option<f32>>

Convert Size<AvailableSpace> into Size<Option<f32>>

pub fn maybe_set(self, value: Size<Option<f32>>) -> Size<AvailableSpace>

If passed value is Some then return AvailableSpace::Definite containing that value, else return self

§

impl<T> Size<T>
where T: TaffyZero,

pub const fn zero() -> Size<T>

Returns a Size where both the width and height values are the zero value of the contained type (e.g. 0.0, Some(0.0), or Dimension::Length(0.0))

§

impl<T> Size<T>
where T: TaffyAuto,

pub const fn auto() -> Size<T>

Returns a Size where both the width and height values are the auto value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

§

impl<T> Size<T>
where T: TaffyMinContent,

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)

§

impl<T> Size<T>
where T: TaffyMaxContent,

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)

§

impl<T> Size<T>
where T: TaffyFitContent,

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.

§

impl<T> Size<T>
where T: FromLength,

pub fn length<Input>(value: Input) -> Size<T>
where Input: Into<f32> + Copy,

Returns a Size where both the width and height values the same given absolute length

§

impl<T> Size<T>
where T: FromPercent,

pub fn percent<Input>(percent_value: Input) -> Size<T>
where Input: Into<f32> + Copy,

Returns a Size where both the width and height values are the constant percent value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Length(2.1))

Trait Implementations§

§

impl<U, T> Add<Size<U>> for Size<T>
where T: Add<U>,

§

type Output = Size<<T as Add<U>>::Output>

The resulting type after applying the + operator.
§

fn add(self, rhs: Size<U>) -> <Size<T> as Add<Size<U>>>::Output

Performs the + operation. Read more
§

impl<T> Clone for Size<T>
where T: Clone,

§

fn clone(&self) -> Size<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for Size<T>
where T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> Default for Size<T>
where T: Default,

§

fn default() -> Size<T>

Returns the “default value” for a type. Read more
§

impl<'de, T> Deserialize<'de> for Size<T>
where T: Deserialize<'de>,

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Size<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<T> From<Point<T>> for Size<T>

§

fn from(value: Point<T>) -> Size<T>

Converts to this type from the input type.
§

impl<T> FromLength for Size<T>
where T: FromLength,

§

fn from_length<Input>(value: Input) -> Size<T>
where Input: Into<f32> + Copy,

Converts into an Into<f32> into Self
§

impl<T> FromPercent for Size<T>
where T: FromPercent,

§

fn from_percent<Input>(percent: Input) -> Size<T>
where Input: Into<f32> + Copy,

Converts into an Into<f32> into Self
§

impl<In, Out, T> MaybeMath<Size<In>, Size<Out>> for Size<T>
where T: MaybeMath<In, Out>,

§

fn maybe_min(self, rhs: Size<In>) -> Size<Out>

Returns the minimum of self and rhs
§

fn maybe_max(self, rhs: Size<In>) -> Size<Out>

Returns the maximum of self and rhs
§

fn maybe_clamp(self, min: Size<In>, max: Size<In>) -> Size<Out>

Returns self clamped between min and max
§

fn maybe_add(self, rhs: Size<In>) -> Size<Out>

Adds self and rhs.
§

fn maybe_sub(self, rhs: Size<In>) -> Size<Out>

Subtracts rhs from self, treating None values as default
§

impl<In, Out, T> MaybeResolve<Size<In>, Size<Out>> for Size<T>
where T: MaybeResolve<In, Out>,

§

fn maybe_resolve(self, context: Size<In>) -> Size<Out>

Converts any parent-relative values for size into an absolute size

§

impl<T> PartialEq for Size<T>
where T: PartialEq,

§

fn eq(&self, other: &Size<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<In, Out, T> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
where In: Copy, Out: TaffyZero, T: ResolveOrZero<In, Out>,

§

fn resolve_or_zero(self, context: Size<In>) -> Rect<Out>

Converts any parent-relative values for Rect into an absolute Rect

§

impl<In, Out, T> ResolveOrZero<Size<In>, Size<Out>> for Size<T>
where Out: TaffyZero, T: ResolveOrZero<In, Out>,

§

fn resolve_or_zero(self, context: Size<In>) -> Size<Out>

Converts any parent-relative values for size into an absolute size

§

impl<T> Serialize for Size<T>
where T: Serialize,

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<U, T> Sub<Size<U>> for Size<T>
where T: Sub<U>,

§

type Output = Size<<T as Sub<U>>::Output>

The resulting type after applying the - operator.
§

fn sub(self, rhs: Size<U>) -> <Size<T> as Sub<Size<U>>>::Output

Performs the - operation. Read more
§

impl<T> TaffyAuto for Size<T>
where T: TaffyAuto,

§

const AUTO: Size<T> = _

The auto value for type implementing TaffyAuto
§

impl<T> TaffyFitContent for Size<T>
where T: TaffyFitContent,

§

fn fit_content(argument: LengthPercentage) -> Size<T>

Converts a LengthPercentage into Self
§

impl<T> TaffyMaxContent for Size<T>
where T: TaffyMaxContent,

§

const MAX_CONTENT: Size<T> = _

The max_content value for type implementing TaffyZero
§

impl<T> TaffyMinContent for Size<T>
where T: TaffyMinContent,

§

const MIN_CONTENT: Size<T> = _

The min_content value for type implementing TaffyZero
§

impl<T> TaffyZero for Size<T>
where T: TaffyZero,

§

const ZERO: Size<T> = _

The zero value for type implementing TaffyZero
§

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> UnwindSafe for Size<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,