| Crates.io | util-cursor |
| lib.rs | util-cursor |
| version | 0.1.0 |
| created_at | 2022-04-10 12:04:54.998538+00 |
| updated_at | 2022-04-10 12:04:54.998538+00 |
| description | A simple cursor implementation for reading data from array slice. |
| homepage | |
| repository | https://github.com/nurmohammed840/util-cursor.rs |
| max_upload_size | |
| id | 565057 |
| size | 5,126 |
A simple cursor implementation for reading data from array slice.
It's similar to std::io::Cursor from std library.
add to your Cargo.toml:
[dependencies]
util-cursor = "0.1"
use util_cursor::Cursor;
let data = [1, 2, 3, 4, 5];
let mut cursor = Cursor::new(data.as_ref());
assert_eq!(cursor.read_slice(3), Some(&[1, 2, 3][..]));
assert_eq!(cursor.offset, 3);
assert_eq!(cursor.remaining_slice(), [4, 5].as_ref());