pub fn optional<I, O>(iter: I, result: Result<I, O>) -> Result<I, Option<O>>where
    I: InputIter,
Expand description

Maps a Result to be optional.

Result::Fail maps to None and Result::Complete maps to Some. The rest of the Result variants are left untouched. You must pass in the iterator that the next matcher should use in the event of a fail.

The optional! macro provides some syntactice sugar for using this combinator properly.