Crate whiteread

Source
Expand description

Crate for reading whitespace-separated values.

The crate defines a trait FromStream, which describes types that can be parsed from whitespace-separated words, which includes eg. integers, tuples, vectors and various adapters.

The definition of whitespace used in this crate is described in SplitAsciiWhitespace.

§Examples

Basics

let (s, i): (String, i32) = parse_string("  answer  42 ").unwrap();

Easy reading from stdin.

let x: i32 = parse_line().unwrap();

Efficient reading from stdin (newline-agnostic) with Reader.

let mut i = Reader::from_stdin_naive();
while let Some(f) = i.parse::<Option<f64>>()? {
    println!("{}", f);
}

Re-exports§

pub use self::stream::FromStream;
pub use self::reader::Reader;

Modules§

adapters
This module defines adapters for FromStream trait.
reader
This module defines the Reader struct.
stream
This module defines the StrStream and FromStream traits

Functions§

parse_file
Parses a whole file as a FromStream value
parse_line
Parse FromStream value from one line of stdin.
parse_stdin
Parse the whole stdin as a FromStream value
parse_string
Parse FromStream value from string.