Skip to main content

Size

Struct 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

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

Applies f32_min to each component separately

Source

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

Source

pub const NONE: Size<Option<f32>>

A Size with None width and height

Source

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

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

Source

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

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_lengths(width: f32, height: f32) -> Size<Dimension>

Generates a Size<Dimension> using length values

Source

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

Generates a Size<Dimension> using percentage 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> Size<T>
where T: TaffyZero,

Source

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

Source§

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

Source

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)

Source§

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

Source

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,

Source

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,

Source

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,

Source

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

Source§

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

Source

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§

Source§

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

Source§

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

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

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

Source§

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

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

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

Source§

fn default() -> Size<T>

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

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts into an Into<f32> into Self
Source§

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

Source§

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

Converts into an Into<f32> into Self
Source§

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

Source§

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

Returns the minimum of self and rhs
Source§

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

Returns the maximum of self and rhs
Source§

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

Returns self clamped between min and max
Source§

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

Adds self and rhs.
Source§

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

Subtracts rhs from self, treating None values as default
Source§

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

Source§

fn maybe_resolve( self, context: Size<In>, calc: impl Fn(*const (), f32) -> f32, ) -> Size<Out>

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

Source§

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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.
Source§

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

Source§

fn resolve_or_zero( self, context: Size<In>, calc: impl Fn(*const (), f32) -> f32, ) -> Rect<Out>

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

Source§

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

Source§

fn resolve_or_zero( self, context: Size<In>, calc: impl Fn(*const (), f32) -> f32, ) -> Size<Out>

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

Source§

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

Source§

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

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

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

Source§

const AUTO: Size<T>

The auto value for type implementing TaffyAuto
Source§

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

Source§

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

Converts a LengthPercentage into Self
Source§

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

Source§

const MAX_CONTENT: Size<T>

The max_content value for type implementing TaffyZero
Source§

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

Source§

const MIN_CONTENT: Size<T>

The min_content value for type implementing TaffyZero
Source§

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

Source§

const ZERO: Size<T>

The zero value for type implementing TaffyZero
Source§

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

Source§

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

Source§

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> 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, dest: *mut u8)

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

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

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

Checks if this value is equivalent to the given key. 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Checks if this value is equivalent to the given key. 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

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,