Macro abortable_parser::optional[][src]

macro_rules! optional {
    ($i:expr, $f:ident) => { ... };
    ($i:expr, $f:ident!( $( $args:tt )* ) ) => { ... };
    (__impl $i:expr, $f:ident!( $( $args:tt )* )) => { ... };
}

Treats a sub parser as optional. It returns Some(output) for a successful match and None for failures.

use abortable_parser::iter;
let input_str = "foo";
let iter = iter::SliceIter::new(input_str.as_bytes());
let result = optional!(iter, text_token!("foo"));