This is the example of how to use the methods of the ReadBytesExt
trait of the byteorder crate:
use std::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt};
let mut rdr = Cursor::new(vec![2, 5, 3, 0]);
assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());
This requires me to specify the byte order every time I call one of the methods on the reader:
rdr.read_u16::<BigEndian>()
Is there a way to get rid of that? Normally a type alias can be used to pack overly verbose type parameters into a convenient name, but I don't know how (and if) that is possible with the trait methods here.