#[non_exhaustive]pub enum MathExpr {
Show 17 variants
Row(Vec<MathExpr>),
Identifier(String),
Number(String),
Operator(String),
OperatorWithMetadata {
text: String,
lspace: Option<f32>,
rspace: Option<f32>,
large_operator: Option<bool>,
movable_limits: Option<bool>,
},
Text(String),
Space(f32),
Fraction {
numerator: Arc<MathExpr>,
denominator: Arc<MathExpr>,
},
Sqrt(Arc<MathExpr>),
Root {
base: Arc<MathExpr>,
index: Arc<MathExpr>,
},
Scripts {
base: Arc<MathExpr>,
sub: Option<Arc<MathExpr>>,
sup: Option<Arc<MathExpr>>,
},
UnderOver {
base: Arc<MathExpr>,
under: Option<Arc<MathExpr>>,
over: Option<Arc<MathExpr>>,
},
Accent {
base: Arc<MathExpr>,
accent: Arc<MathExpr>,
stretch: bool,
},
Fenced {
open: Option<String>,
close: Option<String>,
body: Arc<MathExpr>,
},
Table {
rows: Vec<Vec<MathExpr>>,
column_alignments: Vec<MathColumnAlignment>,
column_gap: Option<f32>,
row_gap: Option<f32>,
},
Source {
source: Range<usize>,
body: Arc<MathExpr>,
},
Error(String),
}Expand description
Presentation-oriented math expression tree, shaped like MathML Core.
Each variant corresponds to a MathML Core element (noted per variant), so
MathML interchange is a near 1:1 mapping. Trees are produced by
parse_tex/parse_mathml (or built directly) and turned into
renderable boxes by layout_math.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Row(Vec<MathExpr>)
Horizontal sequence of sub-expressions (<mrow>).
Identifier(String)
Identifier such as a variable or function name (<mi>); rendered italic.
Number(String)
Numeric literal (<mn>); rendered upright.
Operator(String)
Operator, relation, or punctuation (<mo>). Spacing and big-operator
behavior come from a built-in table keyed on the operator text.
OperatorWithMetadata
Operator (<mo>) with explicit attribute overrides; unset fields fall
back to the built-in operator table used by MathExpr::Operator.
Fields
Text(String)
Literal text rendered upright (<mtext>).
Space(f32)
Horizontal space of the given width in em (<mspace>).
Fraction
Fraction with a horizontal rule (<mfrac>).
Fields
Sqrt(Arc<MathExpr>)
Square root (<msqrt>).
Root
Root with an explicit degree, e.g. a cube root (<mroot>).
Fields
Scripts
Base with attached subscript and/or superscript
(<msub>/<msup>/<msubsup>).
Fields
UnderOver
Base with material placed directly below and/or above it
(<munder>/<mover>/<munderover>), e.g. limits of a sum.
Fields
Accent
Accented base such as a hat or overline (<mover accent="true">).
Fields
Fenced
Body wrapped in (possibly stretchy) fence delimiters (<mfenced>, or
an <mrow> with stretchy <mo> fences).
Fields
Table
Rows and columns of aligned cells (<mtable>), also used for matrix
and aligned/cases TeX environments.
Fields
column_alignments: Vec<MathColumnAlignment>Per-column alignment (MathML columnalign); columns beyond the
list fall back to the last entry or the default (center).
Source
Transparent wrapper recording which byte range of the original source
produced body; emitted by parse_tex_with_source_ranges and
ignored by layout. No MathML equivalent.
Fields
Error(String)
Parse error or unsupported construct; the message is rendered as plain text in place of the expression.
Implementations§
Source§impl MathExpr
impl MathExpr
Sourcepub fn row(children: impl IntoIterator<Item = MathExpr>) -> Self
pub fn row(children: impl IntoIterator<Item = MathExpr>) -> Self
Builds a MathExpr::Row from children, collapsing the trivial
cases: zero children yield an empty row and a single child is
returned as-is without a wrapping row.
Sourcepub fn source_range(&self) -> Option<&Range<usize>>
pub fn source_range(&self) -> Option<&Range<usize>>
Returns the source byte range if this node is a MathExpr::Source
wrapper, without descending into children.
Sourcepub fn without_source(&self) -> &MathExpr
pub fn without_source(&self) -> &MathExpr
Unwraps any (nested) MathExpr::Source wrappers and returns the
underlying expression; returns self for all other variants.
Trait Implementations§
impl StructuralPartialEq for MathExpr
Auto Trait Implementations§
impl Freeze for MathExpr
impl RefUnwindSafe for MathExpr
impl Send for MathExpr
impl Sync for MathExpr
impl Unpin for MathExpr
impl UnsafeUnpin for MathExpr
impl UnwindSafe for MathExpr
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.