From d817f64a252ef572a9ce3d6e758bb7e61caa30cb Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao <629990+naresh97@users.noreply.github.com> Date: Wed, 21 Jan 2026 14:18:22 +0100 Subject: [PATCH] fix ByteBuffer example in README in the example, the ByteBuffer tracks the length & capacity of the allocated vector in bytes. in order to reproduce the original Vec of the correct size, the length in bytes should be divided by element_size --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7177780..c16aedd 100644 --- a/README.md +++ b/README.md @@ -1009,8 +1009,8 @@ impl ByteBuffer { vec![] } else { let element_size = std::mem::size_of::() as i32; - let length = (self.length * element_size) as usize; - let capacity = (self.capacity * element_size) as usize; + let length = (self.length / element_size) as usize; + let capacity = (self.capacity / element_size) as usize; unsafe { Vec::from_raw_parts(self.ptr as *mut T, length, capacity) } }