Crates.io | read_collection |
lib.rs | read_collection |
version | 0.1.5 |
source | src |
created_at | 2024-06-12 18:07:50.59832 |
updated_at | 2024-08-11 08:38:29.949386 |
description | A collection of different variants of the `std::io::Read` trait. |
homepage | https://github.com/TornaxO7/ReadCollection |
repository | https://github.com/TornaxO7/ReadCollection |
max_upload_size | |
id | 1269838 |
size | 100,672 |
This crate provides some other variants of the Read
trait. Currently there's only ReadBack
.
Feel free to create PRs for other variants.
ReadBack
)use read_collection::ReadBack;
use std::io::Read;
fn main() {
let values = [1, 2, 3];
let mut buffer = [0, 0];
// How it could look like with `Read`:
assert_eq!(values.as_slice().read(&mut buffer).ok(), Some(2));
assert_eq!(buffer, [1, 2]);
// With `ReadBack`:
assert_eq!(values.as_slice().read_back(&mut buffer).ok(), Some(2));
// [----] and the buffer contains the value starting from the back!
assert_eq!(buffer, [2, 3]);
}
Implemented: