#[repr(u8)]pub enum ComputedLeaf {
Length(Length),
Percentage(Percentage),
Number(Number),
Angle(Angle),
Time(Time),
Resolution(Resolution),
}Expand description
The computed leaf of a calc() expression.
Variants§
Length(Length)
Percentage(Percentage)
Number(Number)
Angle(Angle)
Time(Time)
Resolution(Resolution)
Implementations§
Source§impl ComputedLeaf
impl ComputedLeaf
pub(super) fn is_zero_length(&self) -> bool
Trait Implementations§
Source§impl CalcNodeLeaf for ComputedLeaf
impl CalcNodeLeaf for ComputedLeaf
Source§fn unitless_value(&self) -> Option<f32>
fn unitless_value(&self) -> Option<f32>
Returns the unitless value of this leaf if one is available.
Source§fn new_number(value: f32) -> Self
fn new_number(value: f32) -> Self
Create a new leaf with a number value.
Source§fn as_angle_radians(&self) -> Option<f32>
fn as_angle_radians(&self) -> Option<f32>
Returns the angle value in radians if this leaf is an angle.
Source§fn new_angle_from_radians(radians: f32) -> Self
fn new_angle_from_radians(radians: f32) -> Self
Creates a new angle leaf from a value in radians.
Source§fn compare(
&self,
other: &Self,
basis: PositivePercentageBasis,
) -> Option<Ordering>
fn compare( &self, other: &Self, basis: PositivePercentageBasis, ) -> Option<Ordering>
Do a partial comparison of these values.
Source§fn try_sum_in_place(&mut self, other: &Self) -> Result<(), ()>
fn try_sum_in_place(&mut self, other: &Self) -> Result<(), ()>
Tries to merge one leaf into another using the sum, that is, perform
x + y.Source§fn try_product_in_place(&mut self, other: &mut Self) -> bool
fn try_product_in_place(&mut self, other: &mut Self) -> bool
Try to merge the right leaf into the left by using a multiplication. Return true if the
merge was successful, otherwise false.
Source§fn try_op<O>(&self, other: &Self, op: O) -> Result<Self, ()>
fn try_op<O>(&self, other: &Self, op: O) -> Result<Self, ()>
Tries a generic arithmetic operation.
Source§fn map(&mut self, op: impl FnMut(f32) -> f32) -> Result<(), ()>
fn map(&mut self, op: impl FnMut(f32) -> f32) -> Result<(), ()>
Map the value of this node with the given operation.
Source§fn is_same_unit_as(&self, other: &Self) -> bool
fn is_same_unit_as(&self, other: &Self) -> bool
Return true if the units of both leaves are equal. (NOTE: Does not take
the values into account)
Source§fn gt(&self, other: &Self, basis_positive: PositivePercentageBasis) -> bool
fn gt(&self, other: &Self, basis_positive: PositivePercentageBasis) -> bool
Return whether a leaf is greater than another.
Source§fn lt(&self, other: &Self, basis_positive: PositivePercentageBasis) -> bool
fn lt(&self, other: &Self, basis_positive: PositivePercentageBasis) -> bool
Return whether a leaf is less than another.
Source§fn lte(&self, other: &Self, basis_positive: PositivePercentageBasis) -> bool
fn lte(&self, other: &Self, basis_positive: PositivePercentageBasis) -> bool
Return whether a leaf is smaller or equal than another.
Source§fn as_number_or_angle_radians(&self) -> Option<f32>
fn as_number_or_angle_radians(&self) -> Option<f32>
Returns a number or angle radians if the leaf is a number or angle.
Source§impl Clone for ComputedLeaf
impl Clone for ComputedLeaf
Source§fn clone(&self) -> ComputedLeaf
fn clone(&self) -> ComputedLeaf
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ComputedLeaf
impl Debug for ComputedLeaf
Source§impl<'de> Deserialize<'de> for ComputedLeaf
impl<'de> Deserialize<'de> for ComputedLeaf
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl MallocSizeOf for ComputedLeaf
impl MallocSizeOf for ComputedLeaf
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
Source§impl PartialEq for ComputedLeaf
impl PartialEq for ComputedLeaf
Source§impl Serialize for ComputedLeaf
impl Serialize for ComputedLeaf
Source§impl ToAnimatedZero for ComputedLeaf
impl ToAnimatedZero for ComputedLeaf
Source§fn to_animated_zero(&self) -> Result<Self, ()>
fn to_animated_zero(&self) -> Result<Self, ()>
Returns a value that, when added with an underlying value, will produce the underlying
value. This is used for SMIL animation’s “by-animation” where SMIL first interpolates from
the zero value to the ‘by’ value, and then adds the result to the underlying value. Read more
Source§impl ToCss for ComputedLeaf
impl ToCss for ComputedLeaf
Source§fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
Serialize
self in CSS syntax, writing to dest.Source§fn to_css_string(&self) -> String
fn to_css_string(&self) -> String
Serialize
self in CSS syntax and return a string. Read moreSource§fn to_css_cssstring(&self) -> String
fn to_css_cssstring(&self) -> String
Serialize
self in CSS syntax and return a CssString. Read moreSource§impl ToResolvedValue for ComputedLeafwhere
Length: ToResolvedValue<ResolvedValue = Length>,
Percentage: ToResolvedValue<ResolvedValue = Percentage>,
Number: ToResolvedValue<ResolvedValue = Number>,
Angle: ToResolvedValue<ResolvedValue = Angle>,
Time: ToResolvedValue<ResolvedValue = Time>,
Resolution: ToResolvedValue<ResolvedValue = Resolution>,
impl ToResolvedValue for ComputedLeafwhere
Length: ToResolvedValue<ResolvedValue = Length>,
Percentage: ToResolvedValue<ResolvedValue = Percentage>,
Number: ToResolvedValue<ResolvedValue = Number>,
Angle: ToResolvedValue<ResolvedValue = Angle>,
Time: ToResolvedValue<ResolvedValue = Time>,
Resolution: ToResolvedValue<ResolvedValue = Resolution>,
Source§type ResolvedValue = ComputedLeaf
type ResolvedValue = ComputedLeaf
The resolved value type we’re going to be converted to.
Source§fn from_resolved_value(from: Self::ResolvedValue) -> Self
fn from_resolved_value(from: Self::ResolvedValue) -> Self
Convert a resolved value to resolved value form.
Source§fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue
fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue
Convert a resolved value to a resolved value.
Source§impl ToTyped for ComputedLeaf
impl ToTyped for ComputedLeaf
Source§fn to_typed_value(&self) -> Option<TypedValue>
fn to_typed_value(&self) -> Option<TypedValue>
Source§fn to_numeric_value(&self) -> Option<NumericValue>
fn to_numeric_value(&self) -> Option<NumericValue>
Source§fn to_typed_value_list(&self) -> Option<TypedValueList>
fn to_typed_value_list(&self) -> Option<TypedValueList>
impl StructuralPartialEq for ComputedLeaf
Auto Trait Implementations§
impl Freeze for ComputedLeaf
impl RefUnwindSafe for ComputedLeaf
impl Send for ComputedLeaf
impl Sync for ComputedLeaf
impl Unpin for ComputedLeaf
impl UnsafeUnpin for ComputedLeaf
impl UnwindSafe for ComputedLeaf
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert