diff options
author | Sam Whited <sam@samwhited.com> | 2017-03-29 09:41:07 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2017-03-29 10:53:45 -0400 |
commit | f8e7685b3a81c52f5448fd77fb4e0535bc92f880 (patch) | |
tree | 20fabbf6f70ba7d0be95e07cd619cd337f2b6a6b /src | |
parent | cac7fc4798425acf63131897eeb04e73a48de91c (diff) | |
download | byteorder-f8e7685b3a81c52f5448fd77fb4e0535bc92f880.tar.gz |
Add examples for {u,i}128 methods
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -232,6 +232,18 @@ pub trait ByteOrder /// # Panics /// /// Panics when `buf.len() < 16`. + /// + /// # Examples + /// + /// Write and read `u128` numbers in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 16]; + /// LittleEndian::write_u128(&mut buf, 1_000_000); + /// assert_eq!(1_000_000, LittleEndian::read_u128(&buf)); + /// ``` #[cfg(feature = "i128")] fn read_u128(buf: &[u8]) -> u128; @@ -261,6 +273,18 @@ pub trait ByteOrder /// /// Panics when `nbytes < 1` or `nbytes > 16` or /// `buf.len() < nbytes` + /// + /// # Examples + /// + /// Write and read an n-byte number in little endian order: + /// + /// ```rust + /// use byteorder::{ByteOrder, LittleEndian}; + /// + /// let mut buf = [0; 3]; + /// LittleEndian::write_uint128(&mut buf, 1_000_000, 3); + /// assert_eq!(1_000_000, LittleEndian::read_uint128(&buf, 3)); + /// ``` #[cfg(feature = "i128")] fn read_uint128(buf: &[u8], nbytes: usize) -> u128; |