Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremiah-shaulov/read_iter
Rust: to any std::io::Read implementor, add also Iterator<Item=u8> implementation.
https://github.com/jeremiah-shaulov/read_iter
Last synced: about 2 months ago
JSON representation
Rust: to any std::io::Read implementor, add also Iterator<Item=u8> implementation.
- Host: GitHub
- URL: https://github.com/jeremiah-shaulov/read_iter
- Owner: jeremiah-shaulov
- License: mit
- Created: 2020-12-06T19:16:03.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-06T22:34:18.000Z (about 4 years ago)
- Last Synced: 2024-10-08T13:54:28.471Z (3 months ago)
- Language: Rust
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# read_iter
[![Documentation](https://docs.rs/read_iter/badge.svg)](https://docs.rs/read_iter)
[![crates.io](https://img.shields.io/crates/v/read_iter.svg)](https://crates.io/crates/read_iter)To any `std::io::Read` implementor, add also `Iterator` implementation.
## Installation
In `Cargo.toml` of your project add:
```toml
[dependencies]
read_iter = "0.1"
```## Examples
```rust
use std::fs::File;
use read_iter::ReadIter;let file = File::open("/tmp/test.txt").unwrap();
// "file" implements std::io::Read
let mut it = ReadIter::new(file);
// now "it" also implements std::io::Read
// and "&mut it" implements Iterator
// also "it" has internal buffer, and implements std::io::BufRead
for byte in &mut it
{ // ...
}
// in case of i/o error, the iteration ends, and take_last_error() will return Err
it.take_last_error().unwrap();
```