3 stable releases
1.0.2 | Jan 28, 2025 |
---|
#898 in Rust patterns
368 downloads per month
4KB
in
A simple Rust crate that provides Python-style input functions through macros.
Installation
Add this to your Cargo.toml
:
[dependencies]
in = "1.0.1"
Usage
This crate provides two macros:
input!()
: Get user input on the same with an optional promptinputln!()
: Same asinput!()
but user input is taken on the next line
Examples
use 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}");
}
License
This project is licensed under the MIT License.