a rusty `scanf` (`scan!`) and inverse of `print!` (`read!`)
a rusty `scanf` (`scan!`) and inverse of `print!` (`read!`)
You can use either the read! macro to read a single value and return it, or
the scan! macro to read one or more values into variables. Both macros can
also read from a file or from memory. The read! macro can take any type that
implements Iterator as an optional third argument, and the scan!
macro's arguments can be prefixed with iter => where iter implements
Iterator.
use text_io::scan;
// reading from a string source
let i: i32;
scan!("12".bytes() => "{}", i);
assert_eq!(i, 12);
// reading multiple values from stdio
let a: i32;
let b: &mut u8 = &mut 5;
scan!("{}, {}", a, *b);…No open issues yet, or sync has not completed.