7 releases

0.2.0 Feb 22, 2022
0.1.5 Feb 19, 2022

#1627 in Rust patterns

Download history 65/week @ 2024-07-27 10/week @ 2024-08-03 6/week @ 2024-08-10 4/week @ 2024-08-17 4/week @ 2024-08-24 3/week @ 2024-08-31 2/week @ 2024-09-07 4/week @ 2024-09-14 19/week @ 2024-09-21 34/week @ 2024-09-28 16/week @ 2024-10-05 18/week @ 2024-10-12 183/week @ 2024-10-19 74/week @ 2024-10-26 43/week @ 2024-11-02 15/week @ 2024-11-09

316 downloads per month
Used in 2 crates

MPL-2.0 license

9KB

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

No runtime deps