pub enum IResult<I, O> {
Done(I, O),
Error,
}Expand description
The result of a parser.
Variants§
Done(I, O)
Parsing succeeded. The first field contains the rest of the unparsed data and the second field contains the parse result.
Error
Parsing failed.
Implementations§
Source§impl<'a, O> IResult<ParseState<'a>, O>
impl<'a, O> IResult<ParseState<'a>, O>
Sourcepub fn expect(self, name: &str) -> O
pub fn expect(self, name: &str) -> O
Unwraps the result, asserting the the parse is complete. Panics with a message based on the given string if the parse failed or is incomplete.
extern crate syn;
#[macro_use] extern crate synom;
use syn::Ty;
use syn::parse::ty;
// One or more Rust types separated by commas.
named!(comma_separated_types -> Vec<Ty>,
separated_nonempty_list!(punct!(","), ty)
);
fn main() {
let input = "&str, Map<K, V>, String";
let parsed = comma_separated_types(input).expect("comma-separated types");
assert_eq!(parsed.len(), 3);
println!("{:?}", parsed);
}Source§impl<'a, O: Eq> IResult<ParseState<'a>, O>
impl<'a, O: Eq> IResult<ParseState<'a>, O>
Sourcepub fn test_looks_like(&self, rest: &str, result: &O) -> bool
pub fn test_looks_like(&self, rest: &str, result: &O) -> bool
This function primarially exists for testing parsers. It returns true if the IResult
“looks like” the passed in parameters. This means that the variant is IResult::Done,
the ParseState::rest() of the input matches rest and the result matches.
Trait Implementations§
impl<I: Eq, O: Eq> Eq for IResult<I, O>
impl<I, O> StructuralPartialEq for IResult<I, O>
Auto Trait Implementations§
impl<I, O> Freeze for IResult<I, O>
impl<I, O> RefUnwindSafe for IResult<I, O>where
I: RefUnwindSafe,
O: RefUnwindSafe,
impl<I, O> Send for IResult<I, O>
impl<I, O> Sync for IResult<I, O>
impl<I, O> Unpin for IResult<I, O>
impl<I, O> UnwindSafe for IResult<I, O>where
I: UnwindSafe,
O: UnwindSafe,
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