#[non_exhaustive]pub enum LengthExpr {
Add(Length, Length),
Sub(Length, Length),
Mul(Length, Factor),
Div(Length, Factor),
Max(Length, Length),
Min(Length, Length),
Abs(Length),
Neg(Length),
Lerp(Length, Length, Factor),
}Expand description
Represents an unresolved Length expression.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Add(Length, Length)
Sums the both layout length.
Sub(Length, Length)
Subtracts the first layout length from the second.
Mul(Length, Factor)
Multiplies the layout length by the factor.
Div(Length, Factor)
Divide the layout length by the factor.
Max(Length, Length)
Maximum layout length.
Min(Length, Length)
Minimum layout length.
Abs(Length)
Computes the absolute layout length.
Neg(Length)
Negate the layout length.
Lerp(Length, Length, Factor)
Linear interpolate between lengths by factor.
Implementations§
Source§impl LengthExpr
impl LengthExpr
Sourcepub fn memory_used(&self) -> ByteLength
pub fn memory_used(&self) -> ByteLength
Gets the total memory allocated by this length expression.
This includes the sum of all nested Length::Expr heap memory.
Sourcepub fn to_length_checked(self) -> Length
pub fn to_length_checked(self) -> Length
Convert to Length::Expr, logs warning for memory use above 1kB, logs error for use > 20kB and collapses to Length::zero.
Every length expression created using the std::ops uses this method to check the constructed expression. Some operations
like iterator fold can cause an expression explosion where two lengths of different units that cannot
be evaluated immediately start an expression that subsequently is wrapped in a new expression for each operation done on it.
Sourcepub fn has_default(&self) -> bool
pub fn has_default(&self) -> bool
If contains a Length::Default value.
Sourcepub fn replace_default(&mut self, overwrite: &Length)
pub fn replace_default(&mut self, overwrite: &Length)
Replace all Length::Default values with overwrite.
Trait Implementations§
Source§impl Clone for LengthExpr
impl Clone for LengthExpr
Source§fn clone(&self) -> LengthExpr
fn clone(&self) -> LengthExpr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LengthExpr
impl Debug for LengthExpr
Source§impl<'de> Deserialize<'de> for LengthExpr
impl<'de> Deserialize<'de> for LengthExpr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for LengthExpr
impl Display for LengthExpr
Source§impl From<LengthExpr> for Length
impl From<LengthExpr> for Length
Source§fn from(expr: LengthExpr) -> Self
fn from(expr: LengthExpr) -> Self
Source§impl FromStr for LengthExpr
impl FromStr for LengthExpr
Source§impl Hash for LengthExpr
impl Hash for LengthExpr
Source§impl Layout1d for LengthExpr
impl Layout1d for LengthExpr
Source§fn layout_dft(&self, axis: LayoutAxis, default: Px) -> Px
fn layout_dft(&self, axis: LayoutAxis, default: Px) -> Px
LAYOUT context with default.Source§fn layout_f32_dft(&self, axis: LayoutAxis, default: f32) -> f32
fn layout_f32_dft(&self, axis: LayoutAxis, default: f32) -> f32
LAYOUT context with default.Source§fn affect_mask(&self) -> LayoutMask
fn affect_mask(&self) -> LayoutMask
LayoutMask that flags all contextual values that affect the result of layout.Source§fn layout(&self, axis: LayoutAxis) -> Px
fn layout(&self, axis: LayoutAxis) -> Px
LAYOUT context.Source§fn layout_dft_x(&self, default: Px) -> Px
fn layout_dft_x(&self, default: Px) -> Px
LAYOUT context x axis with default.Source§fn layout_dft_y(&self, default: Px) -> Px
fn layout_dft_y(&self, default: Px) -> Px
LAYOUT context y axis with default.Source§fn layout_dft_z(&self, default: Px) -> Px
fn layout_dft_z(&self, default: Px) -> Px
LAYOUT context z axis with default.Source§fn layout_f32(&self, axis: LayoutAxis) -> f32
fn layout_f32(&self, axis: LayoutAxis) -> f32
LAYOUT context.Source§fn layout_f32_x(&self) -> f32
fn layout_f32_x(&self) -> f32
LAYOUT context x axis.Source§fn layout_f32_y(&self) -> f32
fn layout_f32_y(&self) -> f32
LAYOUT context y axis.Source§fn layout_f32_z(&self) -> f32
fn layout_f32_z(&self) -> f32
LAYOUT context z axis.Source§fn layout_f32_dft_x(&self, default: f32) -> f32
fn layout_f32_dft_x(&self, default: f32) -> f32
LAYOUT context x axis with default.Source§impl PartialEq for LengthExpr
impl PartialEq for LengthExpr
Source§impl Serialize for LengthExpr
impl Serialize for LengthExpr
impl Eq for LengthExpr
impl IntoValue<Length> for LengthExpr
impl StructuralPartialEq for LengthExpr
Auto Trait Implementations§
impl Freeze for LengthExpr
impl RefUnwindSafe for LengthExpr
impl Send for LengthExpr
impl Sync for LengthExpr
impl Unpin for LengthExpr
impl UnwindSafe for LengthExpr
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more