7 个版本

0.2.0 2022年2月22日
0.1.5 2022年2月19日

#1792 in Rust 模式

Download history 26/week @ 2024-03-14 4/week @ 2024-03-21 16/week @ 2024-03-28 16/week @ 2024-04-04 8/week @ 2024-04-11 10/week @ 2024-04-18 15/week @ 2024-04-25 9/week @ 2024-05-02 8/week @ 2024-05-09 18/week @ 2024-05-16 17/week @ 2024-05-23 15/week @ 2024-05-30 16/week @ 2024-06-06 18/week @ 2024-06-13 20/week @ 2024-06-20 6/week @ 2024-06-27

62 每月下载量
用于 2 crates

MPL-2.0 许可证

9KB

input-macro

Repository Crate Page Documentation License

Rust 的无废话 input!(...) 宏。

示例

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,见 LICENSE

无运行时依赖