diff --git a/src/util.rs b/src/util.rs index 5780c51..7086e4a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -41,7 +41,7 @@ pub fn read8(reader: &mut R) -> Result where R: io::Read { pub fn read16(reader: &mut R) -> Result where R: io::Read { let mut buf = [0u8; 2]; reader.read_exact(&mut buf)?; - Ok(((buf[0] as u16) << 8) + buf[1] as u16) + Ok(u16::from_be_bytes(buf)) } // This function must not be called with more than 4 bytes.