diff options
author | HampusM <hampus@hampusmat.com> | 2024-08-26 20:09:25 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-08-26 20:09:25 +0200 |
commit | 0fc3ba4563895f5437faa2b20a5e93b615dbf25d (patch) | |
tree | a338b10f13a294e876c23572c8c44eda508df4c4 /src | |
parent | d41734115eee6af64d894b46f5a5e628ed127477 (diff) |
feat: add functions to get length & capacity
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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(); |