Parsing the whole string
thecaralice opened this issue · comments
AFAICS the macro searches for a match anywhere in the string provided, which allows "x{}y" to match not only "xAy"
but also things like "BxAyC"
. Is it possible to disable that behaviour, like using ^$
with regex?
Can you write up an MVP to showcase this problem?
Sure, this is what I would expect:
use unfmt::unformat;
fn main() {
assert_eq!(unformat!("({:u8}, {:u8})", "(1, 2)"), Some((1, 2)));
assert_eq!(unformat!("({:u8}, {:u8})", "(1, 2)bar"), None);
assert_eq!(unformat!("({:u8}, {:u8})", "foo(1, 2)bar"), None);
}
We have an undocumented full match feature which will fix this. I just haven't updated the documentation, but it's there. Just add true
as another argument.
Cool, thank you!