diff --git a/src/sharedptr.rs b/src/sharedptr.rs index 115d6c6..5c70540 100644 --- a/src/sharedptr.rs +++ b/src/sharedptr.rs @@ -24,14 +24,12 @@ impl SharedPtr<'_, N> { pub fn get_offset(&self) -> usize { let allocator = ALLOCATOR.lock().unwrap(); - unsafe { - allocator.get_offset(self.as_ptr()) - } + unsafe { allocator.get_offset(self.as_ptr()) } } } impl<'a, const N: usize> Deref for SharedPtr<'a, N> { - type Target = &'a mut [u8; N]; + type Target = [u8; N]; fn deref(&self) -> &Self::Target { &self.0 @@ -65,4 +63,12 @@ mod tests { assert_eq!(x[0], 1); drop(x); } + + #[test] + fn slice() { + let mut x = SharedPtr::<10>::new().unwrap(); + x[0] = 1; + x[1] = 2; + assert_eq!(x[0..=1], [1, 2]); + } }