| Crates.io | in |
| lib.rs | in |
| version | 1.0.2 |
| created_at | 2025-01-28 00:41:10.463781+00 |
| updated_at | 2025-01-28 03:26:56.03156+00 |
| description | Python's input() for Rust |
| homepage | https://github.com/rtificr/input |
| repository | https://github.com/rtificr/input |
| max_upload_size | |
| id | 1533104 |
| size | 3,194 |
A simple Rust crate that provides Python-style input functions through macros.
Add this to your Cargo.toml:
[dependencies]
in = "1.0.1"
This crate provides two macros:
input!(): Get user input on the same with an optional promptinputln!(): Same as input!() but user input is taken on the next lineuse in::input;
use in::inputln;
fn main() {
let a: String = input!();
// Enter a number: x
let x = input!("Enter a number: ").parse::<f32>().unwrap();
// Enter a number:
// x
let y = inputln!("Enter a number: ").parse::<f32>().unwrap();
// x
let z = input!().parse::<f32>().unwrap();
println!("x = {x}");
}
This project is licensed under the MIT License.