nom
nom copied to clipboard
docs: Make `recognize` example more explicit
Hi !
Just wanted to suggest to modify slightly to the recognize
example, as the ordering of the output type is not obvious to me
Here is my suggestion:
use nom::combinator::recognize;
use nom::character::complete::{char, alpha1};
use nom::sequence::separated_pair;
let mut parser = recognize(separated_pair(alpha1, char(','), alpha1));
assert_eq!(parser("abcd,efgh_"), Ok(("_", "abcd,efgh"))); // 'abcd,efgh' is consumed, _ is left
assert_eq!(parser("abcd;"),Err(Err::Error((";", ErrorKind::Char)))); // Missing second part