Skip to main content

LayerRef

Enum LayerRef 

Source
pub(crate) enum LayerRef<'layer> {
    Anonymous {
        start: usize,
        contexts: &'layer [StringContext],
    },
    Named(&'layer Layer),
}
Expand description

A small wrapper around Layer, which allows us to conveniently handle anonymous layers.

Anonymous layers are ParseStack::pending context that hasn’t been added to a layer yet. This means that the outermost parser layer has not been closed.

Since we still want to show this context to users, we need some form of uniform representation for it.

Variants§

§

Anonymous

Fields

§start: usize
§contexts: &'layer [StringContext]
§

Named(&'layer Layer)

Implementations§

Source§

impl<'a> LayerRef<'a>

Source

pub(crate) fn start(self) -> usize

The byte offset where this layer begins.

Source

pub(crate) fn name(self) -> Option<&'a str>

The layer’s name.

None in case of an anonymous layer.

Source

pub(crate) fn label_message(self) -> Option<String>

Returns the optional StringContext::Label messages, joined with commas.

Returns None if there are no StringContext::Label items.

Source

pub(crate) fn descriptions(self) -> Option<String>

All StringContext::Description items joined in a String, without delimiter.

Returns None, if no descriptions exist or if they are all empty.

Source

pub(crate) fn expected_literals(self) -> Vec<String>

Returns a list of all StringContext variants with literal values.

Source

pub(crate) fn label(self) -> Option<&'a str>

Returns the very first StringContext::Label on this layer.

Source

fn contexts(self) -> &'a [StringContext]

Returns a list of all StringContext values.

Trait Implementations§

Source§

impl<'layer> Clone for LayerRef<'layer>

Source§

fn clone(&self) -> LayerRef<'layer>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'layer> Copy for LayerRef<'layer>

Source§

impl<'layer> Debug for LayerRef<'layer>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'layer> Freeze for LayerRef<'layer>

§

impl<'layer> RefUnwindSafe for LayerRef<'layer>

§

impl<'layer> Send for LayerRef<'layer>

§

impl<'layer> Sync for LayerRef<'layer>

§

impl<'layer> Unpin for LayerRef<'layer>

§

impl<'layer> UnsafeUnpin for LayerRef<'layer>

§

impl<'layer> UnwindSafe for LayerRef<'layer>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.