fixed vec mut slice
This commit is contained in:
@@ -52,6 +52,11 @@ impl<const MAX_LEN: usize, T: Sized> FixedVec<MAX_LEN, T> {
|
||||
unsafe { core::slice::from_raw_parts(self.buffer.as_ptr() as *const T, self.length) }
|
||||
}
|
||||
|
||||
pub fn as_slice_mut(&mut self) -> &mut [T] {
|
||||
// length can't be larger than MaxLen, use unsafe to dodge the panic
|
||||
unsafe { core::slice::from_raw_parts_mut(self.buffer.as_mut_ptr() as *mut T, self.length) }
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.length = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user