Struct LC

Source
pub struct LC<T>(pub T, pub (u32, u32, u32));
Expand description

Version of LBox that does not use a Box. This tuple struct contains a value of type T in the first position and a tuple consisting of (line, column, uid) numbers in the second position. The uid or unique identifier is a unique number placed in each LC structure created by the parser. It is useful for hashing information (such as inferred types) based on their source location. Multiple AST constructs may begin with the same line/column position, but the unique id will disambiguate them. This feature was added to Rustlr to support bumpalo-allocated ASTs.

Tuple Fields§

§0: T§1: (u32, u32, u32)

Implementations§

Source§

impl<T> LC<T>

Source

pub fn make(x: T, ln: usize, cl: usize, uid: u32) -> Self

creates a new LC tuple struct in the form (value, (line,column,unique_id))

Source

pub fn new(x: T, ln: usize, cl: usize) -> Self

creates a new LC tuple struct in the form (value, (line,column)) with the unique_id field set to zero (for backwards compatibility)

Source

pub fn line(&self) -> usize

returns encapsulated line

Source

pub fn column(&self) -> usize

returns encapsulated column

Source

pub fn lncl(&self) -> (u32, u32)

returns (line,column) as a pair of 32 values

Source

pub fn uid(&self) -> u32

returns unique id

Source

pub fn value(&self) -> &T

returns value reference

Source

pub fn transfer<U>(&self, x: U) -> LC<U>

transfers line/column information to another LC

Source

pub fn consume(self) -> T

consumes the LC enclosure and returns the enclosed value

Source§

impl<T: Default + ?Sized> LC<T>

Source

pub fn from_lbox(lb: LBox<T>) -> Self

transfers information from an LBox into an LC, consumes LBox

Source§

impl<T: Default + ?Sized> LC<T>

Source

pub fn take(&mut self) -> T

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

Trait Implementations§

Source§

impl<T> AsMut<T> for LC<T>

Source§

fn as_mut(&mut self) -> &mut T

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

impl<T> AsRef<T> for LC<T>

Source§

fn as_ref(&self) -> &T

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

impl<T: Debug> Debug for LC<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for LC<T>

Source§

fn default() -> Self

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

impl<T> Deref for LC<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for LC<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<T> Freeze for LC<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LC<T>
where T: RefUnwindSafe,

§

impl<T> Send for LC<T>
where T: Send,

§

impl<T> Sync for LC<T>
where T: Sync,

§

impl<T> Unpin for LC<T>
where T: Unpin,

§

impl<T> UnwindSafe for LC<T>
where T: UnwindSafe,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.