fix zero_and_clear

This commit is contained in:
Intege-rs
2025-04-11 10:29:16 -04:00
parent b19e81862c
commit 11352fc0ad

View File

@@ -57,17 +57,20 @@ impl<const MAX_LEN: usize, T: Sized> FixedVec<MAX_LEN, T> {
unsafe { core::slice::from_raw_parts_mut(self.buffer.as_mut_ptr() as *mut T, self.length) } unsafe { core::slice::from_raw_parts_mut(self.buffer.as_mut_ptr() as *mut T, self.length) }
} }
pub fn zero_and_clear(&mut self) {
self.as_slice_mut().fill(0);
self.length = 0;
}
pub fn clear(&mut self) { pub fn clear(&mut self) {
self.length = 0; self.length = 0;
} }
} }
impl<const MAX_LEN: usize> FixedVec<MAX_LEN, u8> {
pub fn zero_and_clear(&mut self) {
self.as_slice_mut().fill(0);
self.length = 0;
}
}
impl<const MAX_LEN: usize, T: Debug> Debug for FixedVec<MAX_LEN, T> { impl<const MAX_LEN: usize, T: Debug> Debug for FixedVec<MAX_LEN, T> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
Debug::fmt(self.as_slice(), f) Debug::fmt(self.as_slice(), f)