Trait InputTakeAtPosition

Source
pub trait InputTakeAtPosition: Sized {
    type Item;

    // Required methods
    fn split_at_position<P>(
        &self,
        predicate: P,
    ) -> Result<(Self, Self), Err<Self>>
       where P: Fn(Self::Item) -> bool;
    fn split_at_position1<P>(
        &self,
        predicate: P,
        e: ErrorKind,
    ) -> Result<(Self, Self), Err<Self>>
       where P: Fn(Self::Item) -> bool;
}
Expand description

methods to take as much input as possible until the provided function returns true for the current element

a large part of nom’s basic parsers are built using this trait

Required Associated Types§

Required Methods§

Source

fn split_at_position<P>(&self, predicate: P) -> Result<(Self, Self), Err<Self>>
where P: Fn(Self::Item) -> bool,

Source

fn split_at_position1<P>( &self, predicate: P, e: ErrorKind, ) -> Result<(Self, Self), Err<Self>>
where P: Fn(Self::Item) -> bool,

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

Source§

type Item = char

Source§

fn split_at_position<P>( &self, predicate: P, ) -> Result<(&'a str, &'a str), Err<&'a str>>
where P: Fn(<&'a str as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position1<P>( &self, predicate: P, e: ErrorKind, ) -> Result<(&'a str, &'a str), Err<&'a str>>
where P: Fn(<&'a str as InputTakeAtPosition>::Item) -> bool,

Source§

impl<'a> InputTakeAtPosition for &'a [u8]

Source§

type Item = u8

Source§

fn split_at_position<P>( &self, predicate: P, ) -> Result<(&'a [u8], &'a [u8]), Err<&'a [u8]>>
where P: Fn(<&'a [u8] as InputTakeAtPosition>::Item) -> bool,

Source§

fn split_at_position1<P>( &self, predicate: P, e: ErrorKind, ) -> Result<(&'a [u8], &'a [u8]), Err<&'a [u8]>>
where P: Fn(<&'a [u8] as InputTakeAtPosition>::Item) -> bool,

Implementors§