| Crates.io | RustInput |
| lib.rs | RustInput |
| version | 0.2.0 |
| created_at | 2025-09-25 10:26:55.187264+00 |
| updated_at | 2025-11-04 10:45:26.285226+00 |
| description | A fluent CLI input crate for Rust, supporting all integer, float, bool, and string types; easier to use unlike the standard std::io |
| homepage | |
| repository | https://github.com/lilcloudcoder/RustInput |
| max_upload_size | |
| id | 1854459 |
| size | 8,456 |
Simple, fluent input for Rust CLI apps — easier to use than the standard std::io.
Add to your project's Cargo.toml (example):
[dependencies]
rustinput = { git = "https://github.com/lilcloudcoder/RustInput" }
Note: inside this repository the crate name is RustInput (PascalCase). In external projects, Cargo will expose it as rustinput (snake_case).
// In external projects
use rustinput::input; // or: use rustinput::Input;
fn main() {
let a: i32 = input("Enter i32: ").int();
let b: f64 = input("Enter f64: ").float();
let name = input("Enter name: ").string();
let agree = input("Agree? ").bool();
println!("{a} {b} {name} {agree}");
}
Inside this repo's examples/binary use:
use RustInput::input;
input("Your age: ").int::<i32>()FromStry/yes/true/1, n/no/false/0)char() — read a single characteroptional::<T>() -> Option<T> — Enter to skipdefault::<T>(value) -> T — Enter to accept defaultchoices(&["light", "dark"]) -> String — restrict to allowed values (case-insensitive)use rustinput::input;
let i: i64 = input("i64: ").int();
let u: usize = input("usize: ").int();
let f: f32 = input("f32: ").float();
let s: String = input("name: ").string();
let b: bool = input("ok? ").bool();
let c: char = input("initial: ").char();
let maybe_n: Option<i32> = input("number (Enter to skip): ").optional();
let tries: u32 = input("tries (default 3): ").default(3);
let theme: String = input("theme [light/dark]: ").choices(&["light", "dark"]);
i8..i128, u8..u128, isize, usize)f32, f64