pub trait Input:
Sized
+ Clone
+ Debug
+ Deref<Target = str> {
// Required method
fn split_at(self, mid: usize) -> (Self, Self);
// Provided methods
fn before(self, index: usize) -> Self { ... }
fn after(self, index: usize) -> Self { ... }
fn start(self) -> Self { ... }
fn end(self) -> Self { ... }
}Expand description
This trait represents input that can be parsed by a Parser and/or matched by a Pattern.
An Input must be cheaply cloneable, which is why types like Box<str> or String don’t
implement this trait.
If you want to create an
empty span of the input of a parser, better carve it out of the input to keep the pointer
inside it. Even an empty string can provide info on its location in the source code.
Input::start & Input::end methods will help you with that.
Required Methods§
Sourcefn split_at(self, mid: usize) -> (Self, Self)
fn split_at(self, mid: usize) -> (Self, Self)
A generalisation of str::split_at
Provided Methods§
Sourcefn before(self, index: usize) -> Self
fn before(self, index: usize) -> Self
Equivalent to self.split_at(mid).0, but can be overridden to provide a more optimal
implementation
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".