From 890aaf7335431919edcb5586f6494c23b8171cd6 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 22 Sep 2018 21:58:54 +1000 Subject: [PATCH] Add `num_bytes()` to bitfield --- boolean-bitfield/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boolean-bitfield/src/lib.rs b/boolean-bitfield/src/lib.rs index 717f48776..8328e6350 100644 --- a/boolean-bitfield/src/lib.rs +++ b/boolean-bitfield/src/lib.rs @@ -86,6 +86,9 @@ impl BooleanBitfield { /// vector. pub fn is_empty(&self) -> bool { self.len == 0 } + /// The number of bytes required to represent the bitfield. + pub fn num_bytes(&self) -> usize { self.vec.len() } + /// Iterate through the underlying vector and count the number of /// true bits. pub fn num_true_bits(&self) -> u64 {