[][src]Crate text_io

This crate allows one-liners to read from a terminal A minimal example to get an i32 from the command line is

use text_io::read;

fn main() {
    let i: i32 = read!();
}

The read!() macro will always read until the next ascii whitespace character (\n, \r, \t or space).

Any type that implements the FromStr trait can be read with the read! macro.

Advanced

Text parsing can be done similar to println! by adding a format string to the macro:

use text_io::read;

let i: i32 = read!("The answer: {}!");

This will read "The answer: ", then an integer, then an exclamation mark. Any deviation from the format string will result in a panic.

Note: only a single value can be read per read! invocation.

Macros

read

All text input is handled through this macro

scan

This macro allows to pass several variables so multiple values can be read

try_read
try_scan

Enums

Error

Functions

match_next
parse_capture