pub struct Command<S> { /* private fields */ }
Expand description
A TeX variable command.
Variable commands are resolved to obtain a Variable.
A command consists of three parts.
The first two parts are an immutable getter (of type RefFn) and a mutable getter (of type MutRefFn). Both of these getters accept a reference to the state (where the variable’s value lives) and an Index. The index can be used by the getters to return different values in memory. For example, if the getters read from an array, the index may be just the index in the array. This mechanism allows users of Texlang to write one pair of getters that can be used in many variables.
The third part of a command is an IndexResolver that is used to determine the aforementioned index of a variable at runtime. The process of resolving a command involves determining the Index and returning a Variable type, which under the hood is just the two getters and this index.
Implementations§
source§impl<S> Command<S>
impl<S> Command<S>
sourcepub fn new_singleton<T: SupportedType>(
ref_fn: RefFn<S, T>,
ref_mut_fn: MutRefFn<S, T>
) -> Command<S>
pub fn new_singleton<T: SupportedType>( ref_fn: RefFn<S, T>, ref_mut_fn: MutRefFn<S, T> ) -> Command<S>
Create a new variable command.
sourcepub fn new_array<T: SupportedType>(
ref_fn: RefFn<S, T>,
ref_mut_fn: MutRefFn<S, T>,
index_resolver: IndexResolver<S>
) -> Command<S>
pub fn new_array<T: SupportedType>( ref_fn: RefFn<S, T>, ref_mut_fn: MutRefFn<S, T>, index_resolver: IndexResolver<S> ) -> Command<S>
Create a new variable command.
sourcepub fn new_getter_provider<T: SupportedType>(
ref_fn: RefFn<S, T>,
ref_mut_fn: MutRefFn<S, T>
) -> Command<S>
pub fn new_getter_provider<T: SupportedType>( ref_fn: RefFn<S, T>, ref_mut_fn: MutRefFn<S, T> ) -> Command<S>
Create a new getter provider.
A getter provider is a variable command that is not intended to be invoked directly -
in fact, the variable command will panic the program if it is invoked.
Instead the provider is included in a VM’s initial commands so that
the VM has a reference to the getters inside the command.
If a variable with the same getters is subsequently inserted into the commands map
(for example, by a \countdef
type command), the VM can still serialize that
variable using the getters provided here.