summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-08-26 20:09:25 +0200
committerHampusM <hampus@hampusmat.com>2024-08-26 20:09:25 +0200
commit0fc3ba4563895f5437faa2b20a5e93b615dbf25d (patch)
treea338b10f13a294e876c23572c8c44eda508df4c4 /src
parentd41734115eee6af64d894b46f5a5e628ed127477 (diff)
feat: add functions to get length & capacity
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs12
1 files changed, 12 insertions, 0 deletions
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();