pub trait InputTakeAtPosition: Sized {
    type Item;

    // Required methods
    fn split_at_position<P, E: ParseError<Self>>(
        &self,
        predicate: P
    ) -> IResult<Self, Self, E>
       where P: Fn(Self::Item) -> bool;
    fn split_at_position1<P, E: ParseError<Self>>(
        &self,
        predicate: P,
        e: ErrorKind
    ) -> IResult<Self, Self, E>
       where P: Fn(Self::Item) -> bool;
    fn split_at_position_complete<P, E: ParseError<Self>>(
        &self,
        predicate: P
    ) -> IResult<Self, Self, E>
       where P: Fn(Self::Item) -> bool;
    fn split_at_position1_complete<P, E: ParseError<Self>>(
        &self,
        predicate: P,
        e: ErrorKind
    ) -> IResult<Self, Self, E>
       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§

source

type Item

the current input type is a sequence of that Item type.

example: u8 for &[u8] or char for &str`

Required Methods§

source

fn split_at_position<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

looks for the first element of the input type for which the condition returns true, and returns the input up to this position

streaming version: if no element is found matching the condition, this will return Incomplete

source

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

looks for the first element of the input type for which the condition returns true and returns the input up to this position

fails if the produced slice is empty

streaming version: if no element is found matching the condition, this will return Incomplete

source

fn split_at_position_complete<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

looks for the first element of the input type for which the condition returns true, and returns the input up to this position

complete version: if no element is found matching the condition, this will return the whole input

source

fn split_at_position1_complete<P, E: ParseError<Self>>( &self, predicate: P, e: ErrorKind ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

looks for the first element of the input type for which the condition returns true and returns the input up to this position

fails if the produced slice is empty

complete version: if no element is found matching the condition, this will return the whole input

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> InputTakeAtPosition for &'a str

§

type Item = char

source§

fn split_at_position<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

source§

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

source§

fn split_at_position_complete<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

source§

fn split_at_position1_complete<P, E: ParseError<Self>>( &self, predicate: P, e: ErrorKind ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

source§

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

§

type Item = u8

source§

fn split_at_position<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

source§

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

source§

fn split_at_position_complete<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

source§

fn split_at_position1_complete<P, E: ParseError<Self>>( &self, predicate: P, e: ErrorKind ) -> IResult<Self, Self, E>
where P: Fn(Self::Item) -> bool,

Implementors§