diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2020-04-03 17:34:28 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2020-05-11 15:53:38 +0200 |
commit | bad0aa4e36e6c504627bde16ae95daeb557d301b (patch) | |
tree | df4dfe796e821d845fb823a62648c957633975a1 /openpgp/src/serialize | |
parent | 8e4932b7084ed0ed10fe250b5bdc69bc9001880c (diff) |
openpgp: Use {to,from}_be_bytes.
- Replace bitshifts with the conversion functions from the standard
library.
Diffstat (limited to 'openpgp/src/serialize')
-rw-r--r-- | openpgp/src/serialize/stream/writer/mod.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/openpgp/src/serialize/stream/writer/mod.rs b/openpgp/src/serialize/stream/writer/mod.rs index 705d0048..8aca6891 100644 --- a/openpgp/src/serialize/stream/writer/mod.rs +++ b/openpgp/src/serialize/stream/writer/mod.rs @@ -100,21 +100,17 @@ pub(crate) trait Stackable<'a, C> : io::Write + fmt::Debug { /// Writes a byte. fn write_u8(&mut self, b: u8) -> io::Result<()> { - let b : [u8; 1] = [b; 1]; - self.write_all(&b[..]) + self.write_all(&[b]) } /// Writes a big endian `u16`. fn write_be_u16(&mut self, n: u16) -> io::Result<()> { - let b : [u8; 2] = [ ((n >> 8) & 0xFF) as u8, (n & 0xFF) as u8 ]; - self.write_all(&b[..]) + self.write_all(&n.to_be_bytes()) } /// Writes a big endian `u32`. fn write_be_u32(&mut self, n: u32) -> io::Result<()> { - let b : [u8; 4] = [ (n >> 24) as u8, ((n >> 16) & 0xFF) as u8, - ((n >> 8) & 0xFF) as u8, (n & 0xFF) as u8 ]; - self.write_all(&b[..]) + self.write_all(&n.to_be_bytes()) } } |