Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiwiyou/simput
Simple input parser from stdin
https://github.com/kiwiyou/simput
Last synced: 26 days ago
JSON representation
Simple input parser from stdin
- Host: GitHub
- URL: https://github.com/kiwiyou/simput
- Owner: kiwiyou
- License: mit
- Created: 2020-01-11T16:10:59.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-11T16:41:07.000Z (almost 5 years ago)
- Last Synced: 2024-11-27T18:49:56.800Z (about 1 month ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simput
Simput enables an easy, simple method to get user inputs.
__This is not intended to use in production environment.__## Installation
In `Cargo.toml`:
```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).
```rust
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.
```rust
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);
```