Crate whiteread [−] [src]
Crate for reading whitespace-separated values.
The crate defines a trait White
, which
describes types that can be parsed from whitespace-separated words,
which includes eg. integers, tuples and vectors.
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 WhiteReader
.
Stops on error.
let i = std::io::stdin(); let mut i = WhiteReader::new(i.lock()); while let Ok(f) = i.parse::<f64>() { println!("{}", f); }
If you want better error handling in while-let loops,
use ok_or_none
Reexports
pub use WhiteError::*; |
Structs
Lengthed |
Wrapper for reading vector of values represented by a list prepended by a number of elements. |
SplitAsciiWhitespace |
Fast version of std::str::SplitWhitespace, but with some drawbacks. |
WhiteReader |
Wrapper for BufRead allowing easy parsing values from a Reader. |
Enums
WhiteError |
Error which can occur while parsing |
Traits
StrExt | |
StrStream |
A streaming iterator yielding borrowed strings. |
White |
Trait for values that can be parsed from stream of whitespace-separated words. |
WhiteResultExt |
Trait providing additional methods on |
Functions
open |
Opens a file, and wraps in WhiteReader |
parse_line |
Helper function for parsing |
parse_string |
Helper function for parsing |
Type Definitions
WhiteResult |