read_bytes

Macro read_bytes 

Source
macro_rules! read_bytes {
    ($source:expr, $count:expr) => { ... };
}
Expand description

Reads exactly [$count] bytes from the [$source] and stores them in an array of size [$count]. This macro evaluates to that array.

use kstd::io::cursor::Cursor;
use kstd::read_bytes;
use kstd::io::Read;
fn foo() -> kstd::io::Result<()> {
    let data = vec![0_u8, 1, 2, 3, 4, 5, 6, 7, 8, 9];
    let mut c = Cursor::new(data);
    let buf = read_bytes!(c, 6);
    assert_eq!([0, 1, 2, 3, 4, 5], buf);
    Ok(())
}