Trait texlang::variable::SupportedType

source ·
pub trait SupportedType: Sized {
    // Required methods
    fn new_command<S>(
        ref_fn: RefFn<S, Self>,
        ref_mut_fn: MutRefFn<S, Self>,
        index_resolver: Option<IndexResolver<S>>,
    ) -> Command<S>;
    fn new_typed_variable<S>(
        command: &Command<S>,
        index: Index,
    ) -> Option<TypedVariable<S, Self>>;
    fn try_cast<S>(
        command: &Command<S>,
    ) -> Option<(RefFn<S, Self>, MutRefFn<S, Self>)>;

    // Provided methods
    fn update_save_stack<S>(
        input: &mut ExecutionInput<S>,
        variable: &TypedVariable<S, Self>,
        scope: Scope,
        overwritten_value: Self,
    ) { ... }
    fn recycle<S>(input: &mut ExecutionInput<S>, overwritten_value: Self) { ... }
}
Expand description

Trait satisfied by all Rust types that can be used as TeX variables.

It exists to make the variables API more ergonomic. For example, it is used to provide a uniform constructor Command::new_array for commands. The trait cannot be implemented for new types.

Required Methods§

source

fn new_command<S>( ref_fn: RefFn<S, Self>, ref_mut_fn: MutRefFn<S, Self>, index_resolver: Option<IndexResolver<S>>, ) -> Command<S>

Create a new command of this type with the provided reference functions and index resolver.

source

fn new_typed_variable<S>( command: &Command<S>, index: Index, ) -> Option<TypedVariable<S, Self>>

Create a new typed variable of this type from the getters in the command and the provided index.

Return None if the command has a different type to Self.

source

fn try_cast<S>( command: &Command<S>, ) -> Option<(RefFn<S, Self>, MutRefFn<S, Self>)>

Try to cast a variable command to this type.

Provided Methods§

source

fn update_save_stack<S>( input: &mut ExecutionInput<S>, variable: &TypedVariable<S, Self>, scope: Scope, overwritten_value: Self, )

Update the VM’s save stack after a variable assignment.

source

fn recycle<S>(input: &mut ExecutionInput<S>, overwritten_value: Self)

Recycle a value that’s about to be dropped.

This method is intended for token lists, in which case the vector is returned to the buffers pool.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl SupportedType for i32

source§

fn new_command<S>( ref_fn: RefFn<S, Self>, ref_mut_fn: MutRefFn<S, Self>, index_resolver: Option<IndexResolver<S>>, ) -> Command<S>

source§

fn update_save_stack<S>( input: &mut ExecutionInput<S>, variable: &TypedVariable<S, Self>, scope: Scope, overwritten_value: Self, )

source§

fn new_typed_variable<S>( command: &Command<S>, index: Index, ) -> Option<TypedVariable<S, Self>>

source§

fn try_cast<S>( command: &Command<S>, ) -> Option<(RefFn<S, Self>, MutRefFn<S, Self>)>

source§

impl SupportedType for Vec<Token>

source§

fn new_command<S>( ref_fn: RefFn<S, Self>, ref_mut_fn: MutRefFn<S, Self>, index_resolver: Option<IndexResolver<S>>, ) -> Command<S>

source§

fn update_save_stack<S>( input: &mut ExecutionInput<S>, variable: &TypedVariable<S, Self>, scope: Scope, overwritten_value: Self, )

source§

fn recycle<S>(input: &mut ExecutionInput<S>, overwritten_value: Self)

source§

fn new_typed_variable<S>( command: &Command<S>, index: Index, ) -> Option<TypedVariable<S, Self>>

source§

fn try_cast<S>( command: &Command<S>, ) -> Option<(RefFn<S, Self>, MutRefFn<S, Self>)>

Implementors§