Enum zng_layout::unit::LengthExpr
source · 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§
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.
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 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 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 Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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