Is it possible to read stdin in noncanonical mode under Linux? Non-canonical input means that read() calls to stdin should return as soon as the user enters, which is not the default behavior, as you can see by trying:
// Create a buffer let mut buffer :[u8; 1] = [0]; // Loops over the input from stdin, one character a time while io::stdin().read(&mut buffer).unwrap() > 0 { println!("{:?}", buffer); }
This code expects the user to press return to print the contents of buffer . It is desirable that it prints as you type. The documentation for Stdin (the structure returned by calling stdin() in the above code) does not refer to how this default behavior could be changed.
source share