1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::io::Read;


pub fn read_enter_key() -> Result<(), std::io::Error> {
    let mut stream = std::io::stdin();
    let character = &mut [0u8];

    loop {
        match stream.read(character)? {
            1 if character[0] == b'\n' => return Ok(()),
            0 => continue,
            1 => continue,
            _ => panic!(d!["invariant broken: read of one byte cannot exceed one byte."]),
        }
    }
}