Trait ScanInput

Source
pub trait ScanInput<'a>:
    'a
    + Sized
    + Clone {
    type ScanCursor: ScanCursor<'a>;
    type StrCompare: StrCompare;

    // Required methods
    fn as_str(&self) -> &'a str;
    fn from_subslice(&self, subslice: &'a str) -> Self;
    fn to_cursor(&self) -> Self::ScanCursor;
}
Expand description

This trait is the interface scanners use to access the input being scanned.

Required Associated Types§

Source

type ScanCursor: ScanCursor<'a>

Corresponding cursor type.

Source

type StrCompare: StrCompare

Marker type used to do string comparisons.

Required Methods§

Source

fn as_str(&self) -> &'a str

Get the contents of the input as a string slice.

Source

fn from_subslice(&self, subslice: &'a str) -> Self

Create a new input from a subslice of this input’s contents.

This should be used to ensure that additional state and settings (such as the string comparison marker) are preserved.

Source

fn to_cursor(&self) -> Self::ScanCursor

Turn the input into an independent cursor, suitable for feeding back into a user-facing scanning macro.

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<'a> ScanInput<'a> for &'a str

This implementation is provided to allow scanners to be used manually with a minimum of fuss.

It only supports direct, exact equality comparison.

Source§

type ScanCursor = StrCursor<'a>

Source§

type StrCompare = ExactCompare

Source§

fn as_str(&self) -> &'a str

Source§

fn from_subslice(&self, subslice: &'a str) -> Self

Source§

fn to_cursor(&self) -> Self::ScanCursor

Implementors§

Source§

impl<'a, Cmp, Space, Word> ScanInput<'a> for StrCursor<'a, Cmp, Space, Word>
where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord,

Source§

type ScanCursor = StrCursor<'a, Cmp, Space, Word>

Source§

type StrCompare = Cmp