#[repr(C, u8)]pub enum CalcAstItem {
Value(PixelValue),
Add,
Sub,
Mul,
Div,
BraceOpen,
BraceClose,
}Expand description
A single item in a calc() expression, stored as a flat stack-machine representation.
The expression calc(33.333% - 10px) is stored as:
[Value(33.333%), Sub, Value(10px)]For nested expressions like calc(100% - (20px + 5%)):
[Value(100%), Sub, BraceOpen, Value(20px), Add, Value(5%), BraceClose]Resolution: Walk left to right. When BraceClose is hit, resolve everything
back to the matching BraceOpen, replace that span with a single Value, and continue.
Variants§
Value(PixelValue)
A literal value (e.g. 10px, 33.333%, 2em)
Add
+ operator
Sub
- operator
Mul
* operator
Div
/ operator
BraceOpen
( — opens a sub-expression
BraceClose
) — closes a sub-expression; triggers resolution of the inner span
Trait Implementations§
Source§impl Clone for CalcAstItem
impl Clone for CalcAstItem
Source§fn clone(&self) -> CalcAstItem
fn clone(&self) -> CalcAstItem
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 CalcAstItem
impl Debug for CalcAstItem
Source§impl Extend<CalcAstItem> for CalcAstItemVec
impl Extend<CalcAstItem> for CalcAstItemVec
Source§fn extend<T: IntoIterator<Item = CalcAstItem>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = CalcAstItem>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl FromIterator<CalcAstItem> for CalcAstItemVec
impl FromIterator<CalcAstItem> for CalcAstItemVec
Source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = CalcAstItem>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = CalcAstItem>,
Creates a value from an iterator. Read more
Source§impl Hash for CalcAstItem
impl Hash for CalcAstItem
Source§impl Ord for CalcAstItem
impl Ord for CalcAstItem
Source§fn cmp(&self, other: &CalcAstItem) -> Ordering
fn cmp(&self, other: &CalcAstItem) -> Ordering
1.21.0 · 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 PartialEq for CalcAstItem
impl PartialEq for CalcAstItem
Source§impl PartialOrd for CalcAstItem
impl PartialOrd for CalcAstItem
impl Eq for CalcAstItem
impl StructuralPartialEq for CalcAstItem
Auto Trait Implementations§
impl Freeze for CalcAstItem
impl RefUnwindSafe for CalcAstItem
impl Send for CalcAstItem
impl Sync for CalcAstItem
impl Unpin for CalcAstItem
impl UnsafeUnpin for CalcAstItem
impl UnwindSafe for CalcAstItem
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