How do I write combinators for my own parsers in Rust?
问题 Inspired by this video, I thought a little parser combinator library would be a good way to learn about strings, borrowing and typing in Rust—and it was so far. I managed to get a char parser and a digit parser to work: pub enum Parsed<'a, T> { Some(T, &'a str), None(&'a str), } impl<T> Parsed<'_, T> { // I was neither sure with the third & before the T... pub fn unwrap(&self) -> (&T, &str) { match self { // ... nor with the first one here. Parsed::Some(head, tail) => (&head, &tail), _ =>