Parse files and lists of stringified things into lists of thingified things.
That is, if you've got something Read
-y or Iterator
-y over u8
s,
String
s, or str
s, and a type that implements FromStr
, you can also
have an Iterator
of that type of thing.
Particularly designed to parse files of newline-separated things, like these git integers:
0
1
2
3
4
Load your ints with ease:
```rust,ignore // Create the file of test data use std::fs; let tmpdir = TempDir::new("tmp").unwrap(); let filepath = tmpdir.path().join("list"); fs::write(&filepath, "0\n1\n2\n3\n4").unwrap();
// Load from file. Note that each element could result in an individual
// I/O or parse error. Here those are converted into a single Result<Vec<u32>, _>
.
let v = fromfilelines(&filepath);
let v: Vec
This work is distributed under the super-Rust quad-license:
[Apache-2.0]/[MIT]/[BSL-1.0]/[CC0-1.0]
This is equivalent to public domain in jurisdictions that allow it (CC0-1.0). Otherwise it is compatible with the Rust license, plus the option of the runtime-exception-containing BSL-1. This means that, outside of public domain jurisdictions, the source must be distributed along with author attribution and at least one of the licenses; but in binary form no attribution or license distribution is required.