pub enum Node {
Show 16 variants
Row(Row),
Char(Char),
Text(Box<TextRun>),
Space(Space),
Frac(Box<Frac>),
Sqrt(Box<Sqrt>),
Scripts(Box<Scripts>),
Limits(Box<Limits>),
Fence(Box<Fence>),
Matrix(Box<Matrix>),
Accent(Box<Accent>),
LabeledArrow(Box<LabeledArrow>),
Big(Box<BigOp>),
Styled(Box<Styled>),
Align,
Error(String),
}Expand description
One item of an equation.
Template variants are boxed so that a Node stays pointer sized.
Variants§
Row(Row)
Horizontal sequence of items; an empty row is an empty argument slot.
Char(Char)
A single character with its atom class and font.
Text(Box<TextRun>)
Literal text set upright (\text{...} and friends).
Space(Space)
Explicit horizontal spacing.
Frac(Box<Frac>)
Fraction, with or without a rule.
Sqrt(Box<Sqrt>)
Radical with an optional index.
Scripts(Box<Scripts>)
Subscript and/or superscript attached to a base.
Limits(Box<Limits>)
Over/under material that is not an accent (\overset, \stackrel, limits).
Fence(Box<Fence>)
Delimiters around a body.
Matrix(Box<Matrix>)
Table of cells with optional delimiters and alignment.
Accent(Box<Accent>)
Accent over or under a base.
LabeledArrow(Box<LabeledArrow>)
Arrow carrying text above, below or on both sides.
Big(Box<BigOp>)
Large operator with optional limits.
Styled(Box<Styled>)
Style, font or class applied to a subtree.
Align
Alignment point (& inside aligned environments).
Error(String)
Construct kept verbatim because it could not be represented.
Implementations§
Source§impl Node
impl Node
pub fn row(items: impl IntoIterator<Item = Node>) -> Self
Sourcepub fn char_with(ch: char, class: Class, font: Font) -> Self
pub fn char_with(ch: char, class: Class, font: Font) -> Self
A character carrying class and font.
pub fn text(text: impl Into<String>) -> Self
Sourcepub fn is_empty_slot(&self) -> bool
pub fn is_empty_slot(&self) -> bool
True when the node is an empty row, which renderers draw as an empty slot.
Sourcepub fn slot_count(&self) -> usize
pub fn slot_count(&self) -> usize
Number of child slots the node exposes, in visual order.
Sourcepub fn slot(&self, index: usize) -> Option<&Node>
pub fn slot(&self, index: usize) -> Option<&Node>
Read-only access to slot index, in the order defined by Node::slot_count.
Sourcepub fn slot_mut(&mut self, index: usize) -> Option<&mut Node>
pub fn slot_mut(&mut self, index: usize) -> Option<&mut Node>
Mutable access to slot index, in the order defined by Node::slot_count.
Sourcepub fn slots(&self) -> Vec<&Node>
pub fn slots(&self) -> Vec<&Node>
Slots in visual order. Allocates; use Node::slot_count plus Node::slot in hot paths.
Sourcepub fn walk<'a>(&'a self, visit: &mut impl FnMut(&'a Node))
pub fn walk<'a>(&'a self, visit: &mut impl FnMut(&'a Node))
Depth-first walk over the node and every node reachable through its slots.
Sourcepub fn node_at_mut(&mut self, path: &Path) -> Option<&mut Node>
pub fn node_at_mut(&mut self, path: &Path) -> Option<&mut Node>
Mutable node reached by following path from here.
Sourcepub fn replace_at(&mut self, path: &Path, node: Node) -> Option<Node>
pub fn replace_at(&mut self, path: &Path, node: Node) -> Option<Node>
Replace the node at path, returning the replaced node.
The root cannot be replaced: pass a non-empty path.
Sourcepub fn insert_at(&mut self, path: &Path, node: Node) -> bool
pub fn insert_at(&mut self, path: &Path, node: Node) -> bool
Insert node into the row at path, directly before the item at path or appended when
the path names a row itself.