From 0bc1ede2568d41bcb00a2b0c039a6a33434e6497 Mon Sep 17 00:00:00 2001 From: Intege-rs Date: Sun, 5 Jan 2025 01:58:27 -0500 Subject: [PATCH] fixed vec mut slice --- sub/core/src/arrays.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sub/core/src/arrays.rs b/sub/core/src/arrays.rs index b6dc3ef..f377b80 100644 --- a/sub/core/src/arrays.rs +++ b/sub/core/src/arrays.rs @@ -52,6 +52,11 @@ impl FixedVec { 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; }