[−][src]Enum combine::error::Commit
Enum used to indicate if a parser committed any items of the stream it was given as an input.
This is used by parsers such as or
and choice
to determine if they should try to parse
with another parser as they will only be able to provide good error reporting if the preceding
parser did not commit to the parse.
Variants
Constructor indicating that the parser has committed to this parse. If a parser after this fails,
other parser alternatives will not be attempted (CommitErr
will be returned)
Constructor indicating that the parser has not committed to this parse. If a parser after this fails,
other parser alternatives will be attempted (EmptyErr
will be returned)
Implementations
impl<T> Commit<T>
[src]
pub fn is_peek(&self) -> bool
[src]
Returns true if self
is peek.
pub fn into_inner(self) -> T
[src]
Extracts the contained value.
pub fn into_commit(self) -> Commit<T>
[src]
Converts self
into the Commit
state.
pub fn into_peek(self) -> Commit<T>
[src]
Converts self
into the Peek
state.
pub fn map<F, U>(self, f: F) -> Commit<U> where
F: FnOnce(T) -> U,
[src]
F: FnOnce(T) -> U,
Maps over the contained value without changing the committed state.
pub fn merge(&self, current: Commit<T>) -> Commit<T>
[src]
pub fn combine<F, U, E>(self, f: F) -> StdParseResult2<U, E> where
F: FnOnce(T) -> StdParseResult2<U, E>,
[src]
F: FnOnce(T) -> StdParseResult2<U, E>,
Combines the Commit
flags from self
and the result of f
.
Peek <> Peek -> Peek
Commit <> Peek -> Commit
Peek <> Commit -> Commit
Commit <> Commit -> Commit
//Parses a character of string literal and handles the escaped characters \\ and \" as \ //and " respectively fn char<Input>(input: &mut Input) -> StdParseResult<char, Input> where Input: Stream<Token = char>, Input::Error: ParseError<Input::Token, Input::Range, Input::Position>, { let (c, committed) = satisfy(|c| c != '"').parse_stream(input).into_result()?; match c { //Since the `char` parser has already committed some of the input `combine` is used //propagate the committed state to the next part of the parser '\\' => committed.combine(|_| { satisfy(|c| c == '"' || c == '\\') .map(|c| { match c { '"' => '"', '\\' => '\\', c => c } }) .parse_stream(input) .into_result() }), _ => Ok((c, committed)) } } let result = many(parser(char)) .easy_parse(r#"abc\"\\"#); assert_eq!(result, Ok((r#"abc"\"#.to_string(), ""))); }
pub fn combine_commit<F, U, E>(self, f: F) -> ParseResult<U, E> where
F: FnOnce(T) -> ParseResult<U, E>,
[src]
F: FnOnce(T) -> ParseResult<U, E>,
Trait Implementations
impl<T> AsMut<T> for Commit<T>
[src]
pub fn as_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> AsRef<T> for Commit<T>
[src]
pub fn as_ref(&self) -> &TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T: Clone> Clone for Commit<T>
[src]
impl<T: Copy> Copy for Commit<T>
[src]
impl<T: Debug> Debug for Commit<T>
[src]
impl<T: PartialEq> PartialEq<Commit<T>> for Commit<T>
[src]
impl<T> StructuralPartialEq for Commit<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Commit<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for Commit<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Commit<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Commit<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Commit<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,