Macro nom::u16 [−][src]
if the parameter is nom::Endianness::Big, parse a big endian u16 integer, otherwise a little endian u16 integer
use nom::number::Endianness; named!(be<u16>, u16!(Endianness::Big)); assert_eq!(be(b"\x00\x01abcd"), Ok((&b"abcd"[..], 0x0001))); assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::Size(2)))); named!(le<u16>, u16!(Endianness::Little)); assert_eq!(le(b"\x00\x01abcd"), Ok((&b"abcd"[..], 0x0100))); assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::Size(2))));