Trait Input

Source
pub trait Input:
    Sized
    + Clone
    + Debug
    + Default
    + 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 { ... }
}
Expand description

This trait represents input that can be parsed by a Parser and/or matched by a Pattern

Its Default impl of the type should return a value that represents empty input, akin to an empty string, ""

Required Methods§

Source

fn split_at(self, mid: usize) -> (Self, Self)

A generalisation of str::split_at

Provided Methods§

Source

fn before(self, index: usize) -> Self

Equivalent to self.split_at(mid).0, but can be overridden to provide a more optimal implementation

Source

fn after(self, index: usize) -> Self

Equivalent to self.split_at(mid).1, but can be overriden 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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Input for &str

Source§

fn split_at(self, mid: usize) -> (Self, Self)

Source§

fn before(self, index: usize) -> Self

Source§

fn after(self, index: usize) -> Self

Implementors§