From 34e5d5b612bd89bd9bdbaa51fa9b752d89621b4c Mon Sep 17 00:00:00 2001 From: Brian Langenberger Date: Tue, 29 Dec 2020 12:01:58 -0600 Subject: [PATCH] Add with_capacity creator for BitRecorder --- src/write.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/write.rs b/src/write.rs index 47ac29b..85817ef 100644 --- a/src/write.rs +++ b/src/write.rs @@ -827,6 +827,15 @@ impl BitRecorder { } } + /// Creates new recorder sized for the given number of writes + #[inline] + pub fn with_capacity(writes: usize) -> Self { + BitRecorder { + counter: BitCounter::new(), + records: Vec::with_capacity(writes), + } + } + /// Creates new recorder with the given endiannness #[inline] pub fn endian(_endian: E) -> Self {