rust-si
rust-si copied to clipboard
Scan macro doesn't capture whitespace into strings
let data = String::from("1-5 w:dsjvly wge");
let min: i32;
let max: i32;
let c: char;
let pw: String;
scan!(data.bytes() => "{}-{} {}:{}", min, max, c, pw);
dbg!(pw);
Here, pw
returns dsjvly
only, skipping wge
. How should one get around this so the complete string gets captured?
If your pattern finishes with with anything but a capture, then that would work. So if your data contained a trailing .
and your pattern was also finished by a .
then it would work. I guess we could change scan!
to always parse to the end in case the pattern ends with a placeholder, but this would not really work for using scan!
for stdin or any other infinite input source.