binread 2.2.0

A Rust crate for helping read structs from binary data using ✨macro magic✨
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use binread::{io::Cursor, BinRead};

#[test]
fn derive_generic() {
    #[derive(BinRead)]
    struct Test<T: BinRead<Args = ()> + Default> {
        a: [T; 3],
    }

    let result = Test::<u8>::read(&mut Cursor::new(b"\0\x01\x02")).unwrap();
    assert_eq!(result.a, [0, 1, 2]);
}