~evan-hoose/Snippets

b3bbb28e5098fe466cea3b33f1e2d0bcb946610f — Evan 8 months ago c933cff
 On branch master
 Changes to be committed:
	new file:   read_in.rs
1 files changed, 20 insertions(+), 0 deletions(-)

A read_in.rs
A read_in.rs => read_in.rs +20 -0
@@ 0,0 1,20 @@
use std::io;

fn read_in() {
    let mut buffer = String::new();
    let stdin = io::stdin();

    //pronounced "Red" input.
    let read_input = stdin.read_line(&mut buffer);

    //If line reading fails, try again.
    if read_input.is_err() {
        println!("Unable to read in what you wrote. Please restart.");
        read_date();
    }

    let read_input = read_input.trim();

    return read_input

}