Hello, I’m working on a parser and I’m scanning the input string using a (peekable) iterator.
I have a function that consumes items from the iterator and should return three different things:
- a token if it manages to parse one
- an error message when something goes wrong
- something that tells me that I reached the end of the iteration on the input string.
I have a working example using Option<Result<Token, string>>. It works fine but it doesn’t feel very idiomatic.
What do you think about it? I’d like to know if there is some enum that already combine option and result or if I should roll my own since it would be very easy.