From 029a69a4a56b9c7c913d93cdc5e9902024f2b3fb Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 24 Sep 2018 18:06:47 +1000 Subject: [PATCH] Add method to bitfield to read specific byte --- boolean-bitfield/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/boolean-bitfield/src/lib.rs b/boolean-bitfield/src/lib.rs index 8328e63509..01e8f9f799 100644 --- a/boolean-bitfield/src/lib.rs +++ b/boolean-bitfield/src/lib.rs @@ -117,6 +117,11 @@ impl BooleanBitfield { 0 } + /// Get the byte at a position, assuming big-endian encoding. + pub fn get_byte(&self, n: usize) -> Option<&u8> { + self.vec.get(n) + } + /// Clone and return the underlying byte array (`Vec`). pub fn to_be_vec(&self) -> Vec { let mut o = self.vec.clone();