Use from_be_bytes in one more place.

This commit is contained in:
KAMADA Ken'ichi 2019-03-26 23:25:46 +09:00
parent 46510fef82
commit d04939182d
1 changed files with 1 additions and 1 deletions

View File

@ -41,7 +41,7 @@ pub fn read8<R>(reader: &mut R) -> Result<u8, io::Error> where R: io::Read {
pub fn read16<R>(reader: &mut R) -> Result<u16, io::Error> 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.