Struct Storage

Source
pub struct Storage(/* private fields */);
Expand description

This storage is used by the parser to store the expaned content of a macro call. It is only used when user-defined macros are used. Otherwise, this storage is not used and is zero-overhead.

Storage needs to exist because Rust does not allow self-referencial types. When Rust does (hopefully) gain support for self-referencial types, this storage will be removed.

Implementations§

Source§

impl Storage

Source

pub fn new() -> Self

Create a new storage for the parser.

Examples found in repository?
examples/write_to_string.rs (line 9)
8fn main() {
9    let storage = Storage::new();
10    let parser = Parser::new(INPUT_LATEX, &storage);
11    let mut mathml = String::new();
12    let config = Default::default();
13
14    match push_mathml(&mut mathml, parser, config) {
15        Ok(()) => println!("{}", mathml),
16        Err(e) => eprintln!("Error while rendering: {}", e),
17    }
18}
Source

pub fn reset(&mut self)

Reset the storage’s memory.

It is recommended to call this method after each parsing operation to free up memory. This is more efficient than dropping the storage and creating a new one.

Trait Implementations§

Source§

impl Default for Storage

Source§

fn default() -> Storage

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

Auto Trait Implementations§

§

impl !Freeze for Storage

§

impl !RefUnwindSafe for Storage

§

impl Send for Storage

§

impl !Sync for Storage

§

impl Unpin for Storage

§

impl !UnwindSafe for Storage

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> 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, 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.