Let's say you have a Result<(&str, &str), &str>
, as coming from a lexer. It makes sense to fail if a token matches, so then you want to (!result.map(HelpfulError))?
or (!result).map_err(HelpfulError)?
. Alternatively you need to make your lexer take an &mut &str
(not to be confused with &mut str
) and output bools and use bools everywhere, which is, in fact, a lot easier than trying to work with the existing Result
.
1 Like