Struct taffy::geometry::Size

source ·
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§

source§

impl<T> Size<T>

source

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>

source

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

source

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

Applies the function f to the width

source

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

Applies the function f to the height

source

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

source§

impl Size<f32>

source

pub const ZERO: Size<f32> = _

A Size with zero width and height

source

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

Applies f32_max to each component separately

source§

impl Size<Option<f32>>

source

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

A Size with None width and height

source

pub const fn new(width: f32, height: f32) -> Self

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

source

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.

source§

impl<T> Size<Option<T>>

source

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

Performs Option::unwrap_or on each component separately

source

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

Performs Option::or on each component separately

source

pub fn both_axis_defined(&self) -> bool

Return true if both components are Some, else false.

source§

impl Size<Dimension>

source

pub const fn from_points(width: f32, height: f32) -> Self

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

source

pub const fn from_percent(width: f32, height: f32) -> Self

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

source§

impl Size<AvailableSpace>

source

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

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

source

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

source§

impl<T: TaffyZero> Size<T>

source

pub const fn zero() -> Self

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::Points(0.0))

source§

impl<T: TaffyAuto> Size<T>

source

pub const fn auto() -> Self

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)

source§

impl<T: TaffyMinContent> Size<T>

source

pub const fn min_content() -> Self

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: TaffyMaxContent> Size<T>

source

pub const fn max_content() -> Self

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: TaffyFitContent> Size<T>

source

pub fn fit_content(argument: LengthPercentage) -> Self

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

source§

impl<T: FromPoints> Size<T>

source

pub fn points<Input: Into<f32> + Copy>(points_value: Input) -> Self

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

source§

impl<T: FromPercent> Size<T>

source

pub fn percent<Input: Into<f32> + Copy>(percent_value: Input) -> Self

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::Points(2.1))

Trait Implementations§

source§

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

§

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

The resulting type after applying the + operator.
source§

fn add(self, rhs: Size<U>) -> Self::Output

Performs the + operation. Read more
source§

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

source§

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

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

source§

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

Formats the value using the given formatter. Read more
source§

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

source§

fn default() -> Self

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

impl From<Size<f32>> for SizeAndBaselines

source§

fn from(size: Size<f32>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from_percent<Input: Into<f32> + Copy>(percent: Input) -> Self

Converts into an Into<f32> into Self
source§

impl<T: FromPoints> FromPoints for Size<T>

source§

fn from_points<Input: Into<f32> + Copy>(points: Input) -> Self

Converts into an Into<f32> into Self
source§

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

source§

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

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

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

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

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

source§

const AUTO: Size<T> = _

The auto value for type implementing TaffyZero
source§

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

source§

fn fit_content(argument: LengthPercentage) -> Self

Converts into a LengthPercentage into Self
source§

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

source§

const MAX_CONTENT: Size<T> = _

The max_content value for type implementing TaffyZero
source§

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

source§

const MIN_CONTENT: Size<T> = _

The min_content value for type implementing TaffyZero
source§

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

source§

const ZERO: Size<T> = _

The zero value for type implementing TaffyZero
source§

impl<T: Copy> Copy for Size<T>

source§

impl<T: Eq> Eq for Size<T>

source§

impl<T> StructuralEq for Size<T>

source§

impl<T> StructuralPartialEq for Size<T>

Auto Trait Implementations§

§

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> 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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.