1 unstable release
0.1.0 | Jan 11, 2020 |
---|
#2842 in Rust patterns
4KB
78 lines
Simput
Simput enables an easy, simple method to get user inputs. This is not intended to use in production environment.
Installation
In Cargo.toml
:
[dependencies]
simput = "0.1"
Usage
input!
macro parses input from standard input as a tuple, which contains values of types specified by parameters.
Each values are split by ascii space (0x20) or newline (0x0A).
use simput::input;
let (number, word) = input!(i32, String);
// stdin: 16 Hello
assert_eq!(16, number);
assert_eq!("Hello", word);
You can use Line
keyword to read a whole line.
In this case, a String
is returned.
let i_am_a_line = input!(Line);
// stdin: The quick brown fox jumps over the lazy dog
assert_eq!("The quick brown fox jumps over the lazy dog", i_am_a_line);
Dependencies
~110–255KB