basic_functions/
lib.rs

1/// Waits for keyboard input, mainly to stop a program from exiting before you want it to.
2///
3/// Source: [HeapUnderflow](https://gitlab.com/HeapUnderflow/vidgen/-/blob/57fc60af51dd5d6954aa82f0c9cc99cc63d7db6e/src/main.rs#L97)
4pub fn await_user_input() {
5    use std::io::{stdin, BufRead, BufReader};
6
7    println!("Press [Enter] to exit.");
8
9    let stdin = stdin();
10    let mut read = BufReader::new(stdin.lock());
11
12    let mut garbage = String::new();
13    read.read_line(&mut garbage)
14        .expect("failed to read any input from stdin");
15}