simpler_input/
lib.rs

1pub fn input<'a>(s: impl Into<Option<&'a str>>) -> String {
2	let s_into = s.into();
3	
4	if s_into != None {
5		println!("{}", s_into.unwrap());
6	}
7	
8	let mut val = String::new();
9	std::io::stdin().read_line(&mut val).expect("Something went wrong with the input.");
10	
11	return val[0..val.len() - 1].to_string();
12}
13
14#[cfg(test)]
15mod tests {
16    use super::*;
17    
18    #[test]
19    fn input_test() {
20        let a = input(None);
21        let b = input("Hello there");
22        
23        assert_eq!(a, "hello");
24        assert_eq!(b, "test");
25    }
26}