pub struct Chain<T, U, P1, P2> { /* private fields */ }
Expand description
Chains two parsers together.
Follows error coercion rules.
let mut input = ParserString::from("abc ");
let (string, after) = word.chain(whitespace).parse(&mut input)?;
assert_eq!(string, "abc");
assert_eq!(after, 3);
Implementations§
Trait Implementations§
Source§impl<T, U, P1, P2, E> Parser<(T, U)> for Chain<T, U, P1, P2>
impl<T, U, P1, P2, E> Parser<(T, U)> for Chain<T, U, P1, P2>
Source§fn parse(&self, s: &mut ParserString) -> Result<(T, U), Self::Err>
fn parse(&self, s: &mut ParserString) -> Result<(T, U), Self::Err>
Run this parser, using a
ParserString
.Source§fn try_parse(&self, s: &mut ParserString) -> Result<T, Self::Err>
fn try_parse(&self, s: &mut ParserString) -> Result<T, Self::Err>
Run this parser without affecting the string on failure. In other words, the string will be
“rewinded” on failure.
Source§fn chain<U, P2: Parser<U, Err = E>, E: Into<Self::Err>>(
self,
other: P2,
) -> Chain<T, U, Self, P2>
fn chain<U, P2: Parser<U, Err = E>, E: Into<Self::Err>>( self, other: P2, ) -> Chain<T, U, Self, P2>
Constructs a
Chain
combinator.Source§fn or<P2: Parser<T, Err = E>, E: Into<Self::Err>>(
self,
other: P2,
) -> Or<T, E, Self, P2>
fn or<P2: Parser<T, Err = E>, E: Into<Self::Err>>( self, other: P2, ) -> Or<T, E, Self, P2>
Constructs a
Or
combinator.Source§fn map<U: 'static>(
self,
f: impl Fn(T) -> U + 'static,
) -> impl Parser<U, Err = Self::Err>
fn map<U: 'static>( self, f: impl Fn(T) -> U + 'static, ) -> impl Parser<U, Err = Self::Err>
Apply a function to the output of this parser on success.
Source§fn map_err<E: 'static>(
self,
f: impl Fn(Self::Err) -> E + 'static,
) -> impl Parser<T, Err = E>
fn map_err<E: 'static>( self, f: impl Fn(Self::Err) -> E + 'static, ) -> impl Parser<T, Err = E>
Apply a function to the
Err
output of this parser on failure.Source§fn and_then<U: 'static, E: Into<Self::Err>>(
self,
f: impl Fn(T) -> Result<U, E> + 'static,
) -> impl Parser<U, Err = Self::Err>
fn and_then<U: 'static, E: Into<Self::Err>>( self, f: impl Fn(T) -> Result<U, E> + 'static, ) -> impl Parser<U, Err = Self::Err>
Applies a function to the output of this parser on success, using error coercion rules.
Source§fn after<U, P2: Parser<U, Err = E>, E: Into<Self::Err>>(
self,
other: P2,
) -> impl Parser<T, Err = Self::Err>
fn after<U, P2: Parser<U, Err = E>, E: Into<Self::Err>>( self, other: P2, ) -> impl Parser<T, Err = Self::Err>
Similar to
Chain
, but only keeps the output of the first parser.Auto Trait Implementations§
impl<T, U, P1, P2> Freeze for Chain<T, U, P1, P2>
impl<T, U, P1, P2> RefUnwindSafe for Chain<T, U, P1, P2>
impl<T, U, P1, P2> Send for Chain<T, U, P1, P2>
impl<T, U, P1, P2> Sync for Chain<T, U, P1, P2>
impl<T, U, P1, P2> Unpin for Chain<T, U, P1, P2>
impl<T, U, P1, P2> UnwindSafe for Chain<T, U, P1, P2>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more