pub fn empty<Input, Error>(_input: &mut Input) -> Result<(), Error>where
Input: Stream,
Error: ParserError<Input>,
Expand description
Succeed, consuming no input
For example, it can be used as the last alternative in alt
to
specify the default case.
Useful with:
Note: This never advances the Stream
§Example
use winnow::combinator::alt;
use winnow::combinator::empty;
fn sign(input: &mut &str) -> ModalResult<isize> {
alt((
'-'.value(-1),
'+'.value(1),
empty.value(1)
)).parse_next(input)
}
assert_eq!(sign.parse_peek("+10"), Ok(("10", 1)));
assert_eq!(sign.parse_peek("-10"), Ok(("10", -1)));
assert_eq!(sign.parse_peek("10"), Ok(("10", 1)));