pub struct LBox<T: ?Sized> {
    pub exp: Box<T>,
    pub line: u32,
    pub column: u32,
}
Expand description

Custom smart pointer that encapsulates line and column numbers along with a regular Box. Implements Deref and DerefMut so the encapsulated expression can be accessed as in a standard Box. This is intended to to be used in the formation of abstract syntax trees so that the lexical information is available for each construct after the parsing stage.

Fields

exp: Box<T>line: u32column: u32

Implementations

should be used to create a new LBoxed expression that inherits lexical information from existing LBox

Since version 0.2.4, Rustlr now stores the line and column information internally as u32 values instead of usize, and the LBox::line and LBox::column functions are provided for interface

replaces the boxed value with T::default() and returns the value

emulates Box::downcast function, when LBox<dyn Any> is used as the abstract syntax type. Note that unlike Box::downcast, an Option is returned here instead of a result.

do not try to create a LBox<dyn Any> structure with something like

 let lb:LBox<dyn Any> = LBox::new(String::from("abc"),0,0);

This does not work as LBox is simply borrowing the underlying mechanics of Box instead of re-creating them. Do instead:

 let lb:LBox<dyn Any> = LBox::upcast(LBox::new(String::from("abc"),0,0));

upcast always returns a LBox<dyn Any>.

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

this is provided so LBox<dyn Any> can be used for the abstract syntax type. the default is a Lbox containing a static string.

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

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.