Smart Read
Complex but easy ways to read user input
Anything that implements TryRead can be used with the read and prompt macros, and features are added by creating new implementations of this trait. For a list of default implementations, just go to the main docs page.
Qualities
- Extremely Customizable, basically anything can be implemented
- Extremely Simple, for both using and extending
- Extremely Ergonomic, everything is as effortless as possible
Basic Usage
// read a line of text
let _ = read!;
// prompt a line of text
let _ = prompt!;
// read specific types
let _ = read!;
let _ = read!;
let _ = read!;
let _ = read!;
// read a number within a range
let _ = read!;
// read a bool
let _ = prompt!;
// set a default value
let _ = prompt!;
// choose from a list of options
let _ = read!;
// some input type have special syntax
let _ = read!;
// one-time custom logic
let _ = prompt!;
// combine any features
let _ = prompt!;
Example stdout (from the read_lines example)
==== `read!(0. ..= 100.)` ====
Enter a number within the range [0.0, 100.0]: 100.0001
Invalid input, not within bounds
Enter a number within the range [0.0, 100.0]: aa
Could not parse input (error: invalid float literal)
Enter a number within the range [0.0, 100.0]: 1.
You entered: "1"
Extend Existing Functionality
use *;
// choose from a list of cars
Add New Functionality
use *;
// take in a password input