diff --git a/src/t_array.rs b/src/t_array.rs index 1d5b4c0..cc60c94 100644 --- a/src/t_array.rs +++ b/src/t_array.rs @@ -36,6 +36,20 @@ impl TArray { } } + pub fn capacity(&self) -> u32 { + self.cap + } + + pub fn clear(&mut self, len: u32) -> Self { + if self.data_ptr != 0 && self.len > 0 { + let data = unsafe { + std::slice::from_raw_parts_mut(self.data_ptr as *mut u8, self.len) + }; + data.fill(0); + self.len = 0; + } + } + #[inline(always)] pub(crate) fn resize_grow(&mut self, count: Option) -> u32 { let count = count.unwrap_or(1);