rust-si icon indicating copy to clipboard operation
rust-si copied to clipboard

Scan macro doesn't capture whitespace into strings

Open adnan449 opened this issue 4 years ago • 1 comments

    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?

adnan449 avatar Dec 05 '20 02:12 adnan449

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.

oli-obk avatar Dec 07 '20 11:12 oli-obk