You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice it must call pinteger() twice. This is to make the borrow checker happy, but it also makes sense because (I expect?) each positive() will need internal state.
What if instead the Parser objects supported .clone() and/or Copy? Then it would not need to execute the code in positive() every time, and also the "fn"s and their <'a> boilerplate would be unnecessary. For example the code could just say:
let integerPattern = one_of("123456789") - one_of("0123456789").repeat(0..) | sym('0');
let positive = integerPattern.collect().convert(|s|String::from_iter(s.iter()).parse::())
let range = positive.clone() - sym('-') + positive.clone()
This is a lot less typing because the signatures are not needed.
The text was updated successfully, but these errors were encountered:
Here is a simple sample program that uses Pom to decode a list of ranges, like "30-42,10-40".
To parse an integer it adapts number() from the sample code:
Then it uses this like
Notice it must call pinteger() twice. This is to make the borrow checker happy, but it also makes sense because (I expect?) each positive() will need internal state.
What if instead the Parser objects supported .clone() and/or Copy? Then it would not need to execute the code in positive() every time, and also the "fn"s and their <'a> boilerplate would be unnecessary. For example the code could just say:
let integerPattern = one_of("123456789") - one_of("0123456789").repeat(0..) | sym('0');
let positive = integerPattern.collect().convert(|s|String::from_iter(s.iter()).parse::())
let range = positive.clone() - sym('-') + positive.clone()
This is a lot less typing because the signatures are not needed.
The text was updated successfully, but these errors were encountered: