pub struct Constructor {Show 21 fields
pub cs: Token,
pub nargs: Option<usize>,
pub paramlist: Option<Parameters>,
pub replacement: Option<ReplacementClosure>,
pub sizer: Option<SizingClosure>,
pub before_digest: Vec<BeforeDigestClosure>,
pub after_digest: Vec<DigestionClosure>,
pub before_construct: Vec<ConstructionClosure>,
pub after_construct: Vec<ConstructionClosure>,
pub properties: PropertiesClosure,
pub capture_body: bool,
pub after_digest_body: Vec<DigestionClosure>,
pub reversion: Option<Reversion>,
pub alias: Option<String>,
pub origin: DefinitionOrigin,
pub declared_mode: Option<DeclaredMode>,
pub font: Option<FontDirective>,
pub halign_primitive: bool,
pub template: Option<&'static str>,
pub salvage_end: Option<(Token, Vec<DigestionClosure>)>,
pub salvage_close: Vec<DigestionClosure>,
}Fields§
§cs: Token§nargs: Option<usize>§paramlist: Option<Parameters>§replacement: Option<ReplacementClosure>§sizer: Option<SizingClosure>§before_digest: Vec<BeforeDigestClosure>§after_digest: Vec<DigestionClosure>§before_construct: Vec<ConstructionClosure>§after_construct: Vec<ConstructionClosure>§properties: PropertiesClosure§capture_body: bool§after_digest_body: Vec<DigestionClosure>§reversion: Option<Reversion>§alias: Option<String>§origin: DefinitionOrigin§declared_mode: Option<DeclaredMode>The mode options def_constructor compiled into before_digest (K13).
font: Option<FontDirective>The font option def_constructor compiled into before_digest (Definition::declared_font).
halign_primitive: boolTeX’s \halign primitive (tex_tables.rs) or a binding’s stand-in that takes its place (pgfsys-latexml’s SVG
matrix \lxSVG@halign): what a document’s \halign macro ends with when it is run before an alignment the
bindings build (latexml_engine tex_tables.rs run_halign_redefinition_prelude), under whatever name it was saved.
template: Option<&'static str>The XML template its replacement was compiled from, when it is a literal one (DefConstructor! with a string
replacement); none for a closure replacement or a constructor made at run time. Read by
Definition::replacement_template.
salvage_end: Option<(Token, Vec<DigestionClosure>)>An environment’s opener (\begin{X}, the bare \X): its end’s token (\end{X}, \endX) and the
after_digest hooks its binding gave that end, without the end’s mode or group closer. A digestion Fatal in its
body closes the body with that end’s trailer, run through these hooks, then ends its mode as end_mode would (OD
#251, #1237; def_environment).
salvage_close: Vec<DigestionClosure>Run on its whatsit when a digestion Fatal ends its body or last argument (OD #251), where its close would run
them: the end of a pair its opener began (end_caption_box for begin_caption_box), never its other close code.
Implementations§
Source§impl Constructor
impl Constructor
Digest through the Rc<Constructor> the state table already holds, instead
of deep-cloning the definition for every invocation.
Every Whatsit keeps a back-reference to the definition that built it
(Whatsit::definition), and Definition::invoke_primitive fills that
slot with Rc::new(self.clone()) — a fresh deep clone per invocation,
carrying the Parameters and all three Vec<Rc<dyn Fn…>> hook lists with
it. Those clones are not transient: a Whatsit lives in the digested tree
for the whole Build, so a document retains one private copy of the
constructor per construct it uses. Measured with dhat (2026-07-29, debug
profile, math-dense fixture): the Rc<Constructor> itself was 1,215 blocks
/ 349,920 B — an exact 1:1 with the 1,215 constructor invocations — plus
3,638 blocks / 314,816 B inside <Constructor as Clone>::clone for the
parameters and hook vectors.
The state table’s entry is Stored::Constructor(Rc<Constructor>)
(common/store.rs), so the invoker is already holding a shareable handle;
passing it through turns that whole per-invocation cost into a refcount
bump. Sharing is sound because the definition is immutable once installed —
nothing calls Rc::get_mut on it, and PartialEq for Whatsit compares
definitions by value (*self.definition == *other.definition), so a
shared handle compares exactly as a private clone did.
Trait Implementations§
Source§impl Clone for Constructor
impl Clone for Constructor
Source§impl Debug for Constructor
impl Debug for Constructor
Source§impl Default for Constructor
impl Default for Constructor
Source§impl Definition for Constructor
impl Definition for Constructor
Source§fn invoke_primitive(&self) -> Result<Vec<Digested>>
fn invoke_primitive(&self) -> Result<Vec<Digested>>
Digest the constructor; This should occur in the Stomach to create a Whatsit. The whatsit which will be further processed to create the document.
Allocates a fresh Rc for the Whatsit’s back-reference. Callers that
already hold the state table’s Rc<Constructor> should use
Constructor::invoke_primitive_shared instead, which reuses it — see
there for why that matters.
Source§fn declared_mode(&self) -> Option<DeclaredMode>
fn declared_mode(&self) -> Option<DeclaredMode>
DeclaredMode); None for definitions
not made by a definer that takes mode options (macros, registers, raw-TeX definitions,
a primitive built by hand). The audit reads None on a primitive or constructor as
declaring nothing.Source§fn declared_font(&self) -> Option<&FontDirective>
fn declared_font(&self) -> Option<&FontDirective>
font => {…} option), which its
digestion merges into the current font; None for every other definition. latex.ltx’s
\@fontswitch reads a math alphabet as a switch to the group’s end (\mathrm\relax with
\math@bgroup let to \relax, latex.ltx:14312-14321): the binding’s switch merges this font
(\lx@math@alphabet@switch, latex_constructs/sect13.rs).Source§fn replacement_template(&self) -> Option<&'static str>
fn replacement_template(&self) -> Option<&'static str>
DefConstructor!
with a string replacement), when no construction hook (before_construct, after_construct) adds to it. None
for a closure replacement, a constructor made at run time and every other definition: what it builds cannot be
read off it (the frontmatter’s no-ink test, latexml_engine util_text.rs first_ink, counts such a whatsit as ink).fn before_digest(&self) -> Option<&Vec<BeforeDigestClosure>>
fn after_digest(&self) -> Option<&Vec<DigestionClosure>>
fn after_digest_body(&self) -> Option<&Vec<DigestionClosure>>
fn capture_body(&self) -> bool
fn get_sizer(&self) -> Option<SizingClosure>
fn invoke(&self, _once_only: bool) -> Result<Tokens>
Source§fn get_cs(&self) -> Cow<'_, Token>
fn get_cs(&self) -> Cow<'_, Token>
fn get_cs_name(&self) -> Cow<'_, str>
fn get_alias(&self) -> Option<&String>
fn get_parameters(&self) -> Option<&Parameters>
fn get_num_args(&self) -> usize
fn do_absorption( &self, document: &mut Document, whatsit: &Whatsit, ) -> Result<Vec<Node>>
fn get_reversion_spec(&self) -> Option<Reversion>
Source§fn invoke_onto_input(&self, once_only: bool) -> Result<()>
fn invoke_onto_input(&self, once_only: bool) -> Result<()>
Self::invoke’s result pushed back with crate::gullet::unread_expansion, as
the gullet’s macro expansion does. An expandable with a token-list body substitutes its arguments straight
onto the input instead (tex.web §390 macro_call).Source§fn native_expansion(&self) -> Result<Option<Tokens>>
fn native_expansion(&self) -> Result<Option<Tokens>>
expandable::SpecialCall::Native, for a call the gullet expands in full: only there, so a one-step
\expandafter and every other reader of the expansion get the macro’s own body.fn get_cs_or_alias(&self) -> Cow<'_, Token>
fn is_protected(&self) -> bool
Source§fn peeks_by_futurelet(&self) -> bool
fn peeks_by_futurelet(&self) -> bool
\@ifnextchar does (1756-1760): by \futurelet, behind an unexpandable
\let. A number scan (tex.web §445) ends at such a macro instead of
expanding it (see gullet::expands_now). A binding closure that makes an
assignment as it expands carries it too when its TeX original reaches an
unexpandable token (\begingroup, \let, \relax) before it acts:
etoolbox’s \newrobustcmd and \patchcmd, amsthm’s \pushQED.fn is_register(&self) -> bool
fn is_prefix(&self) -> bool
fn is_readonly(&self) -> bool
fn get_test(&self) -> Option<&ConditionalClosure>
fn get_conditional_type(&self) -> Option<ConditionalType>
fn read_arguments(&self) -> Result<Vec<ArgWrap>>where
Self: Sized,
fn invocation( &mut self, args: Vec<Option<Tokens>>, _gullet: &mut Gullet, ) -> Result<Tokens>
fn execute_before_digest(&self) -> Result<Vec<Digested>>
fn execute_after_digest(&self, whatsit: &mut Whatsit) -> Result<Vec<Digested>>
fn execute_after_digest_body( &self, whatsit: &mut Whatsit, ) -> Result<Vec<Digested>>
fn value_of(&self, _args: Vec<ArgWrap>) -> Option<RegisterValue>
Source§fn set_value(
&self,
_value: RegisterValue,
_scope: Option<Scope>,
_args: Vec<ArgWrap>,
) -> Result<()>
fn set_value( &self, _value: RegisterValue, _scope: Option<Scope>, _args: Vec<ArgWrap>, ) -> Result<()>
fn register_type(&self) -> Option<RegisterType>
fn get_expansion(&self) -> Option<&ExpansionBody>
fn stringify_type(&self, deftype: &str) -> String
Source§impl Display for Constructor
impl Display for Constructor
Source§impl From<Constructor> for Stored
impl From<Constructor> for Stored
Source§fn from(value: Constructor) -> Self
fn from(value: Constructor) -> Self
Source§impl Object for Constructor
impl Object for Constructor
fn stringify(&self) -> String
fn isa_box(&self) -> bool
fn is_expandable(&self) -> bool
fn is_definition(&self) -> bool
fn is_comment(&self) -> bool
fn be_digested(self) -> Result<Digested>
Source§fn get_locator(&self) -> Option<Locator>
fn get_locator(&self) -> Option<Locator>
None is the honest
“no recorded source position” (replacing the old Locator::default()
file!()/line!() sentinel). For “where the parser is now” (error
reporting, box creation), use the free fn gullet::get_locator().Source§fn get_origin(&self) -> DefinitionOrigin
fn get_origin(&self) -> DefinitionOrigin
definition::origin). The
default is Unknown, which counts as LaTeXML’s own.