pub trait LayerExt<'i, O>: Parser<Input<'i>, O, ErrMode<ParseStack<'i>>> + Sized {
// Provided method
fn layer(self, name: impl Into<String>) -> LayerParser<Self> { ... }
}Expand description
Extension trait that adds a LayerExt::layer function to all parsers
Calling layer allows creation of nested LayerParser on any parser over the
Input type.
A layer acts as a boundary of the currently parsed unit of “grammar”. All context errors since the last layer (if existing) are bound to this layer.
§Note
The order in which Parser::context and layer functions are called is important!
A layer contains all context calls that were called beforehand.
Any context calls after layer will be part of the next layer.
§Example
use alpm_parsers::prelude::*;
use winnow::ascii::alphanumeric1;
let mut parser = alphanumeric1.label("alphanumeric number").layer("version");
parser.parse(Input::new("a1"))?;Provided Methods§
Sourcefn layer(self, name: impl Into<String>) -> LayerParser<Self>
fn layer(self, name: impl Into<String>) -> LayerParser<Self>
Wraps this parser in a named nesting layer.
On failure any pending context messages are moved into a named layer, spanning from where the parser started to where it failed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".