#cursor #slice #array #reading #data #utils

util-cursor

A simple cursor implementation for reading data from array slice

1 unstable release

0.1.0 Apr 10, 2022

#66 in #cursor

MIT license

4KB

A simple cursor implementation for reading data from array slice. It's similar to std::io::Cursor from std library.

Usage

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());

No runtime deps