7 releases

0.2.0 Feb 22, 2022
0.1.5 Feb 19, 2022

#1576 in Rust patterns

Download history 2/week @ 2024-07-21 66/week @ 2024-07-28 10/week @ 2024-08-04 5/week @ 2024-08-11 4/week @ 2024-08-18 5/week @ 2024-08-25 2/week @ 2024-09-01 2/week @ 2024-09-08 5/week @ 2024-09-15 20/week @ 2024-09-22 32/week @ 2024-09-29 18/week @ 2024-10-06 20/week @ 2024-10-13 180/week @ 2024-10-20 75/week @ 2024-10-27 39/week @ 2024-11-03

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