From 0fc3ba4563895f5437faa2b20a5e93b615dbf25d Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 26 Aug 2024 20:09:25 +0200 Subject: feat: add functions to get length & capacity --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 424b366..5eb4439 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,6 +115,18 @@ where unsafe { field_ptr.cast().as_ref() } } + /// Returns the number of items stored in this `MultiVec`. + pub fn len(&self) -> usize + { + self.length + } + + /// Returns how many items this `MultiVec` has capacity for. + pub fn capacity(&self) -> usize + { + self.capacity + } + fn grow_amortized(&mut self, additional: usize) { let required_cap = self.capacity.checked_add(additional).unwrap(); -- cgit v1.2.3-18-g5258