mirror of
https://github.com/mrfluffy-dev/kami.git
synced 2026-01-17 12:50:32 +00:00
refactor: restructure
This commit is contained in:
31
src/helpers/take_input.rs
Normal file
31
src/helpers/take_input.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::io::{self, Write};
|
||||
|
||||
pub fn string_input(prompt: &str) -> String {
|
||||
print!("{}", prompt);
|
||||
let mut input = String::new();
|
||||
let _ = io::stdout().flush();
|
||||
io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("Error reading from STDIN");
|
||||
input.trim().to_string()
|
||||
}
|
||||
|
||||
pub fn int_input(prompt: &str) -> usize {
|
||||
print!("{}", prompt);
|
||||
let mut input = String::new();
|
||||
let _ = io::stdout().flush();
|
||||
io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("Error reading from STDIN");
|
||||
input.trim().parse::<usize>().unwrap()
|
||||
}
|
||||
|
||||
pub fn u16_input(prompt: &str) -> u16 {
|
||||
print!("{}", prompt);
|
||||
let mut input = String::new();
|
||||
let _ = io::stdout().flush();
|
||||
io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("Error reading from STDIN");
|
||||
input.trim().parse::<u16>().unwrap()
|
||||
}
|
||||
Reference in New Issue
Block a user