I read about reading integer input in How to read an integer input from the user in Rust 1.0?, but I noticed that all the solutions first take a string as input and then convert it to integer. I wonder if there's a way to read an integer directly.
This page mentions scan!()
macro but for some reason it doesn't seem to run when I compile the following program using rustc main.rc
.
extern crate text_io;
fn main() {
let mut a: u8;
let mut b: u8;
scan!("{},{}", a, b);
print!("{} {}", a, b);
}
This produces the error:
error: macro undefined: 'scan!'
scan!("{},{}",a,b);