Skip to main content

Constructor

Struct Constructor 

Source
pub struct Constructor {
Show 14 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>,
}

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>

Implementations§

Source§

impl Constructor

Source

pub fn invoke_primitive_shared(me: &Rc<Constructor>) -> Result<Vec<Digested>>

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

Source§

fn clone(&self) -> Constructor

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 Constructor

Source§

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

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

impl Default for Constructor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Definition for Constructor

Source§

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 before_digest(&self) -> Option<&Vec<BeforeDigestClosure>>

Source§

fn after_digest(&self) -> Option<&Vec<DigestionClosure>>

Source§

fn after_digest_body(&self) -> Option<&Vec<DigestionClosure>>

Source§

fn capture_body(&self) -> bool

Source§

fn get_sizer(&self) -> Option<SizingClosure>

Source§

fn invoke(&self, _once_only: bool) -> Result<Tokens>

Source§

fn get_cs(&self) -> Cow<'_, Token>

We can almost always return the CS by reference, except in a Register’s RefCell, where we are forced to clone
Source§

fn get_cs_name(&self) -> Cow<'_, str>

Source§

fn get_alias(&self) -> Option<&String>

Source§

fn get_parameters(&self) -> Option<&Parameters>

Source§

fn get_num_args(&self) -> usize

Source§

fn do_absorption( &self, document: &mut Document, whatsit: &Whatsit, ) -> Result<Vec<Node>>

Source§

fn get_reversion_spec(&self) -> Option<Reversion>

Source§

fn get_cs_or_alias(&self) -> Cow<'_, Token>

Source§

fn is_protected(&self) -> bool

Source§

fn is_register(&self) -> bool

Source§

fn is_prefix(&self) -> bool

Source§

fn is_readonly(&self) -> bool

Source§

fn get_test(&self) -> Option<&ConditionalClosure>

Source§

fn get_conditional_type(&self) -> Option<ConditionalType>

Source§

fn read_arguments(&self) -> Result<Vec<ArgWrap>>
where Self: Sized,

Source§

fn invocation( &mut self, args: Vec<Option<Tokens>>, _gullet: &mut Gullet, ) -> Result<Tokens>

Source§

fn execute_before_digest(&self) -> Result<Vec<Digested>>

Source§

fn execute_after_digest(&self, whatsit: &mut Whatsit) -> Result<Vec<Digested>>

Source§

fn execute_after_digest_body( &self, whatsit: &mut Whatsit, ) -> Result<Vec<Digested>>

Source§

fn value_of(&self, _args: Vec<ArgWrap>) -> Option<RegisterValue>

Source§

fn set_value( &self, _value: RegisterValue, _scope: Option<Scope>, _args: Vec<ArgWrap>, )

runs the setter to assign the value for a register
Source§

fn register_type(&self) -> Option<RegisterType>

Source§

fn get_expansion(&self) -> Option<&ExpansionBody>

Source§

fn stringify_type(&self, deftype: &str) -> String

Source§

impl Display for Constructor

Source§

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

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

impl From<Constructor> for Stored

Source§

fn from(value: Constructor) -> Self

Converts to this type from the input type.
Source§

impl Object for Constructor

Source§

fn stringify(&self) -> String

Source§

fn isa_box(&self) -> bool

Source§

fn is_expandable(&self) -> bool

Source§

fn is_definition(&self) -> bool

Source§

fn is_comment(&self) -> bool

Source§

fn be_digested(self) -> Result<Digested>
where Self: Sized + Debug,

Source§

fn get_locator(&self) -> Option<Locator>

The object’s stored source locator, if it has one. 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 revert(&self) -> Result<Tokens>

each concrete object needs to provide its own path back to tokens
Source§

impl PartialEq for Constructor

Source§

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

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

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

Inequality operator !=. Read more

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.