pub enum CalcableValue<'a, T> {
Literal(T),
Substituted(Box<'a, CalcableSubstitutionFunction<'a, T>>),
Unresolved(Box<'a, Unresolved<'a>>),
}Expand description
Generic wrapper for numeric CSS values whose grammar permits both arbitrary substitution
functions and typed math functions (calc(), min(), max(), etc.).
Used for: <length>, <length-percentage>, <number>, <percentage>, <integer>,
<time>, <angle>, <frequency>, <flex>, <alpha-value>, etc.
Structurally identical to Value except CalcableSubstitutionFunction adds a Math variant.
Variants§
Literal(T)
Substituted(Box<'a, CalcableSubstitutionFunction<'a, T>>)
Unresolved(Box<'a, Unresolved<'a>>)
Trait Implementations§
Source§impl<'a, T: Clone> Clone for CalcableValue<'a, T>
impl<'a, T: Clone> Clone for CalcableValue<'a, T>
Source§fn clone(&self) -> CalcableValue<'a, T>
fn clone(&self) -> CalcableValue<'a, T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T: Debug> Debug for CalcableValue<'a, T>
impl<'a, T: Debug> Debug for CalcableValue<'a, T>
Source§impl<'a, T> DeclarationValue<'a, CssMetadata> for CalcableValue<'a, T>where
T: Parse<'a> + Peek<'a> + ToCursors + ToSpan + SemanticEq + NodeWithMetadata<CssMetadata> + DeclarationValue<'a, CssMetadata>,
impl<'a, T> DeclarationValue<'a, CssMetadata> for CalcableValue<'a, T>where
T: Parse<'a> + Peek<'a> + ToCursors + ToSpan + SemanticEq + NodeWithMetadata<CssMetadata> + DeclarationValue<'a, CssMetadata>,
Source§fn is_initial(&self) -> bool
fn is_initial(&self) -> bool
Determines if the parsed Self was parsed as the “initial” keyword. Read more
Source§fn is_inherit(&self) -> bool
fn is_inherit(&self) -> bool
Determines if the parsed Self was parsed as the “inherit” keyword. Read more
Source§fn is_unset(&self) -> bool
fn is_unset(&self) -> bool
Determines if the parsed Self was parsed as the “unset” keyword. Read more
Source§fn is_revert(&self) -> bool
fn is_revert(&self) -> bool
Determines if the parsed Self was parsed as the “revert” keyword. Read more
Source§fn is_revert_layer(&self) -> bool
fn is_revert_layer(&self) -> bool
Determines if the parsed Self was parsed as the “revert” keyword. Read more
Source§fn needs_computing(&self) -> bool
fn needs_computing(&self) -> bool
Determines if the parsed Self is not a valid literal production of the grammar, and instead some of its
constituent parts will need additional computation to reify into a known value. Read more
Source§fn parse_specified_declaration_value<Iter>(
p: &mut Parser<'a, Iter>,
name: Cursor,
) -> Result<Self>
fn parse_specified_declaration_value<Iter>( p: &mut Parser<'a, Iter>, name: Cursor, ) -> Result<Self>
Like
parse() but with the additional context of the name Cursor. This is only called on values that are
assumed to be specified, that is, they’re not custom and not computed. Therefore this should return a Self
reflecting a specified value. If this results in a Parse error then ComputedValue will be checked to see if the
parser stopped because it saw a computed value function. If this results in a success, the next token is still
checked as it may be a ComputedValue, which - if so - the parsed value will be discarded, and the parser rewound
to re-parse this as a ComputedValue. Read moreSource§fn declaration_metadata(declaration: &Declaration<'a, Self, M>) -> M
fn declaration_metadata(declaration: &Declaration<'a, Self, M>) -> M
Returns metadata for this value when used in a declaration context.
This allows the value to inspect the declaration (e.g., checking for !important)
and include that information in the metadata. Read more
Source§fn is_unknown(&self) -> bool
fn is_unknown(&self) -> bool
Determines if the parsed Self was parsed as an unknown value. Read more
Source§fn is_custom(&self) -> bool
fn is_custom(&self) -> bool
Determines if the parsed Self was parsed as a Custom value. Read more
Source§fn parse_custom_declaration_value<Iter>(
p: &mut Parser<'a, Iter>,
_name: Cursor,
) -> Result<Self, Diagnostic>
fn parse_custom_declaration_value<Iter>( p: &mut Parser<'a, Iter>, _name: Cursor, ) -> Result<Self, Diagnostic>
Like
parse() but with the additional context of the name Cursor. This cursor is known to be dashed ident,
therefore this should return a Self reflecting a Custom property. Alternatively, if this DeclarationValue
disallows custom declarations then this is the right place to return a parse Error. Read moreSource§fn parse_computed_declaration_value<Iter>(
p: &mut Parser<'a, Iter>,
_name: Cursor,
) -> Result<Self, Diagnostic>
fn parse_computed_declaration_value<Iter>( p: &mut Parser<'a, Iter>, _name: Cursor, ) -> Result<Self, Diagnostic>
Like
parse() but with the additional context of the name Cursor. This is only called before verifying that
the next token was peeked to be a ComputedValue, therefore this should return a Self reflecting a Computed
property. Alternatively, if this DeclarationValue disallows computed declarations then this is the right place to
return a parse Error. Read moreSource§fn parse_unknown_declaration_value<Iter>(
p: &mut Parser<'a, Iter>,
_name: Cursor,
) -> Result<Self, Diagnostic>
fn parse_unknown_declaration_value<Iter>( p: &mut Parser<'a, Iter>, _name: Cursor, ) -> Result<Self, Diagnostic>
Like
parse() but with the additional context of the name Cursor. This is only called on values that are
didn’t parse as either a Custom, Computed or Specified value therefore this should return a Self reflecting an
unknown property, or alternatively the right place to return a parse error. Read morefn parse_declaration_value<Iter>( p: &mut Parser<'a, Iter>, name: Cursor, ) -> Result<Self, Diagnostic>
impl<'a, T: Eq> Eq for CalcableValue<'a, T>
Source§impl<'a, T: Hash> Hash for CalcableValue<'a, T>
impl<'a, T: Hash> Hash for CalcableValue<'a, T>
Source§impl<'a, T: NodeWithMetadata<CssMetadata>> NodeWithMetadata<CssMetadata> for CalcableValue<'a, T>
impl<'a, T: NodeWithMetadata<CssMetadata>> NodeWithMetadata<CssMetadata> for CalcableValue<'a, T>
Source§fn metadata(&self) -> CssMetadata
fn metadata(&self) -> CssMetadata
Returns the complete aggregated metadata for this node (self + children).
Default implementation merges children’s metadata with self_metadata().
Source§fn self_metadata(&self) -> M
fn self_metadata(&self) -> M
Returns the metadata contributed by this node itself, not including children.
Most nodes don’t contribute metadata, so can simply return
M::default().
Nodes like StyleRule or AtRules should return their own node kind flags here.Source§impl<'a, T: Ord> Ord for CalcableValue<'a, T>
impl<'a, T: Ord> Ord for CalcableValue<'a, T>
Source§fn cmp(&self, other: &CalcableValue<'a, T>) -> Ordering
fn cmp(&self, other: &CalcableValue<'a, T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a, T: PartialEq> PartialEq for CalcableValue<'a, T>
impl<'a, T: PartialEq> PartialEq for CalcableValue<'a, T>
Source§impl<'a, T: PartialOrd> PartialOrd for CalcableValue<'a, T>
impl<'a, T: PartialOrd> PartialOrd for CalcableValue<'a, T>
Source§impl<'a, T> Peek<'a> for CalcableValue<'a, T>where
T: Peek<'a>,
impl<'a, T> Peek<'a> for CalcableValue<'a, T>where
T: Peek<'a>,
Source§impl<'a, T> SemanticEq for CalcableValue<'a, T>where
T: SemanticEq,
impl<'a, T> SemanticEq for CalcableValue<'a, T>where
T: SemanticEq,
Source§fn semantic_eq(&self, other: &Self) -> bool
fn semantic_eq(&self, other: &Self) -> bool
Returns
true if self and other are semantically equal.impl<'a, T: PartialEq> StructuralPartialEq for CalcableValue<'a, T>
Source§impl<'a, T> ToCursors for CalcableValue<'a, T>where
T: ToCursors,
impl<'a, T> ToCursors for CalcableValue<'a, T>where
T: ToCursors,
fn to_cursors(&self, s: &mut impl CursorSink)
Source§impl<T: ToNormalisedValue> ToNormalisedValue for CalcableValue<'_, T>
impl<T: ToNormalisedValue> ToNormalisedValue for CalcableValue<'_, T>
fn to_normalised_value(&self) -> Option<f32>
Source§impl<T: ToNumberValue> ToNumberValue for CalcableValue<'_, T>
impl<T: ToNumberValue> ToNumberValue for CalcableValue<'_, T>
fn to_number_value(&self) -> Option<f32>
fn to_int_value(&self) -> Option<i32>
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for CalcableValue<'a, T>
impl<'a, T> !Send for CalcableValue<'a, T>
impl<'a, T> !Sync for CalcableValue<'a, T>
impl<'a, T> !UnwindSafe for CalcableValue<'a, T>
impl<'a, T> Freeze for CalcableValue<'a, T>where
T: Freeze,
impl<'a, T> Unpin for CalcableValue<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for CalcableValue<'a, T>where
T: UnsafeUnpin,
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