input-macro

Crates.ioinput-macro
lib.rsinput-macro
version0.2.0
sourcesrc
created_at2022-02-19 05:35:14.085017
updated_at2022-02-22 21:42:59.231563
descriptionNo-nonsense input!(...) macro for Rust.
homepage
repositoryhttps://github.com/sunsetkookaburra/input-macro
max_upload_size
id535035
size25,504
Oli Lenehan (sunsetkookaburra)

documentation

https://docs.rs/input-macro

README

input-macro

Repository Crate Page Documentation License

No-nonsense input!(...) macro for Rust.

Example

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 😋.");
        },
    }
}

License

MPL v2.0, see LICENSE

Commit count: 10

cargo fmt