use std::io;
fn main()
{
let mut input = String::new();
match io::stdin().read_line(&mut input)
{
Ok(_) => println!("input: {}", input),
Err(_) => println!("Error!"),
}
}
So with this program, I am a bit confused with Ok(_) and Err(_) inside the match statement. So with the match statement, this line io::stdin().read_line(&mut input), does it output something? Cause like I tried to print this but I got an error.
So what is it exactly outputting? Does it output Ok(_) if it ran fine? Also with the function Ok(_), if I don't want to pass in the byte size b to retrieve how many bytes my input was, then how come the Ok() function accepts _ this argument?
The underscore _ is a special pattern that matches any value, and ignores it. You can use it whenever you don't care about the contents of the thing you are matching.