pub fn optional<P: Pattern>(pattern: P) -> Repetition<P>Expand description
Returns a new pattern that matches 0 or 1 repetitions of pattern
This implies the new pattern always matches the input.
use bparse::{Pattern, optional};
assert_eq!(optional("a").eval(b"b"), Some(0));
assert_eq!(optional("a").eval(b"a"), Some(1));