read_input 0.5.3

A simple tool that asks for data until the data is valid.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//To run this example `cargo run --example match --release`
//This example shows how best to use `match` on a inputted value.
//The thing to note form this program is the use of `unreachable!()`

extern crate dont_disappear;
extern crate read_input;

use read_input::*;

fn main() {
    match valid_input(|x| 2 <= *x && *x <= 4) {
        2 => println!("You inputted the number 2"),
        3 => println!("You inputted the number 3"),
        4 => println!("You inputted the number 4"),
        _ => unreachable!(),
    }
    dont_disappear::enter_to_continue::default();
}