#[macro_export]
macro_rules! cin {
($prompt:expr, $t:ty) => {{
$crate::__cin_read!($prompt)
.parse::<$t>()
.unwrap_or_else(|_| panic!("Failed to parse input as {}", stringify!($t)))
}};
($t:ty) => {{
cin!("Prompt: ", $t)
}};
($prompt:expr) => {{
$crate::__cin_read!($prompt)
}};
() => {{
cin!("Prompt: ")
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __cin_read {
($prompt:expr) => {{
use std::io::{self, Write};
if !$prompt.is_empty() {
print!("{}", $prompt);
io::stdout().flush().expect("Failed to flush stdout");
}
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("Failed to read from stdin");
input.trim().to_string()
}};
}