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§
Implementations§
Source§impl<'a> LayerRef<'a>
impl<'a> LayerRef<'a>
Sourcepub(crate) fn name(self) -> Option<&'a str>
pub(crate) fn name(self) -> Option<&'a str>
The layer’s name.
None in case of an anonymous layer.
Sourcepub(crate) fn label_message(self) -> Option<String>
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.
Sourcepub(crate) fn descriptions(self) -> Option<String>
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.
Sourcepub(crate) fn expected_literals(self) -> Vec<String>
pub(crate) fn expected_literals(self) -> Vec<String>
Returns a list of all StringContext variants with literal values.
Sourcepub(crate) fn label(self) -> Option<&'a str>
pub(crate) fn label(self) -> Option<&'a str>
Returns the very first StringContext::Label on this layer.
Sourcefn contexts(self) -> &'a [StringContext]
fn contexts(self) -> &'a [StringContext]
Returns a list of all StringContext values.