Skip to main content

Node

Enum Node 

Source
pub enum Node {
Show 15 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>), 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.

§

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

Source

pub fn empty() -> Self

An empty row, i.e. an empty slot.

Source

pub fn row(items: impl IntoIterator<Item = Node>) -> Self

Source

pub fn char_with(ch: char, class: Class, font: Font) -> Self

A character carrying class and font.

Source

pub fn variable(ch: char) -> Self

A default-class italic variable.

Source

pub fn symbol(ch: char, class: Class) -> Self

A default-class upright operator or symbol.

Source

pub fn text(text: impl Into<String>) -> Self

Source

pub fn is_empty_slot(&self) -> bool

True when the node is an empty row, which renderers draw as an empty slot.

Source

pub fn is_row(&self) -> bool

Whether the node is a row and can therefore accept siblings.

Source

pub fn slot_count(&self) -> usize

Number of child slots the node exposes, in visual order.

Source

pub fn slot(&self, index: usize) -> Option<&Node>

Read-only access to slot index, in the order defined by Node::slot_count.

Source

pub fn slot_mut(&mut self, index: usize) -> Option<&mut Node>

Mutable access to slot index, in the order defined by Node::slot_count.

Source

pub fn slots(&self) -> Vec<&Node>

Slots in visual order. Allocates; use Node::slot_count plus Node::slot in hot paths.

Source

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.

Source

pub fn node_at(&self, path: &Path) -> Option<&Node>

Node reached by following path from here.

Source

pub fn node_at_mut(&mut self, path: &Path) -> Option<&mut Node>

Mutable node reached by following path from here.

Source

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.

Source

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.

Source

pub fn remove_at(&mut self, path: &Path) -> Option<Node>

Remove the node at path, returning it. The root cannot be removed.

Source

pub fn normalize(&mut self)

Flatten rows nested directly inside a row and drop empty nested rows.

Template slots are untouched, so this only removes row nesting that carries no meaning and keeps parse-then-serialise round trips stable.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Node

Source§

fn default() -> Self

An empty slot.

Source§

impl Eq for Node

Source§

impl From<&str> for Node

Source§

fn from(text: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Node

Source§

fn from(text: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Node>> for Node

Source§

fn from(items: Vec<Node>) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Node

Source§

fn from(ch: char) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.