Crates.io | input-macro |
lib.rs | input-macro |
version | 0.2.0 |
source | src |
created_at | 2022-02-19 05:35:14.085017 |
updated_at | 2022-02-22 21:42:59.231563 |
description | No-nonsense input!(...) macro for Rust. |
homepage | |
repository | https://github.com/sunsetkookaburra/input-macro |
max_upload_size | |
id | 535035 |
size | 25,504 |
No-nonsense input!(...)
macro for Rust.
use input_macro::input;
fn main() {
let name = input!("What's your name? ");
println!("Hello, {name}!");
let age: i64 = input!("How old are you today, {name}? ").parse().unwrap();
match age {
i if i < 0 => {
println!("Whoah, negative age! Impressive! 🌌");
},
_ => {
println!("Happy Birthday! Congratulations! 🥳");
},
}
match input!("Do you like chocolate 🍫 (y/N)? ").as_str() {
"y" | "Y" => {
println!("Yay! I like chocolate too 🙂.");
},
_ => {
println!("Oh well, all the more for me 😋.");
},
}
}
MPL v2.0, see LICENSE