Struct rustlr::generic_absyn::LBox
source · [−]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: u32
column: u32
Implementations
sourceimpl<T> LBox<T>
impl<T> LBox<T>
pub fn new(e: T, ln: usize, col: usize) -> LBox<T>
sourcepub fn transfer<U>(&self, e: U) -> LBox<U>
pub fn transfer<U>(&self, e: U) -> LBox<U>
should be used to create a new LBoxed expression that inherits lexical information from existing LBox
sourcepub fn line(&self) -> usize
pub fn line(&self) -> usize
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
pub fn column(&self) -> usize
sourceimpl<'t> LBox<dyn Any + 't>
impl<'t> LBox<dyn Any + 't>
sourcepub fn downcast<U: 't>(self) -> Option<LBox<U>>
pub fn downcast<U: 't>(self) -> Option<LBox<U>>
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.
sourcepub fn upcast<T: 't>(lb: LBox<T>) -> Self
pub fn upcast<T: 't>(lb: LBox<T>) -> Self
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
sourceimpl Default for LBox<dyn Any>
impl Default for LBox<dyn Any>
this is provided so LBox<dyn Any>
can be used for the abstract syntax type.
the default is a Lbox containing a static string.
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for LBox<T> where
T: RefUnwindSafe,
impl<T: ?Sized> Send for LBox<T> where
T: Send,
impl<T: ?Sized> Sync for LBox<T> where
T: Sync,
impl<T: ?Sized> Unpin for LBox<T>
impl<T: ?Sized> UnwindSafe for LBox<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more