I was going to do something more clever with having a higher-order Parser on top of the Iterator, but by the time I got done with the checkbox parsing (with its optionals etc), I realized I'd just basically written a few convenience methods on top of the parser, but still needed the low-level ones (like next() or peek()). So, this just adds the conveniences.
I could imagine an even higher-level abstraction, where for example I specify an enum and get back which if any of its string-equivalent-variants was next; basically a parser.peek_one_of( { "foo", "bar", "baz" } ). But without static typing (ie if I literally just pass in a Vec<&str> it doesn't feel very compelling, and with static typing (ie an enum) it feels too heavyweight. At least for now.
I was going to do something more clever with having a higher-order Parser on top of the Iterator, but by the time I got done with the checkbox parsing (with its optionals etc), I realized I'd just basically written a few convenience methods on top of the parser, but still needed the low-level ones (like
next()
orpeek()
). So, this just adds the conveniences.I could imagine an even higher-level abstraction, where for example I specify an enum and get back which if any of its string-equivalent-variants was next; basically a
parser.peek_one_of( { "foo", "bar", "baz" } )
. But without static typing (ie if I literally just pass in aVec<&str>
it doesn't feel very compelling, and with static typing (ie an enum) it feels too heavyweight. At least for now.