From 43aa454a292da9c4d8a456a7347f89761e2af3b1 Mon Sep 17 00:00:00 2001 From: Aaron Kaiser Date: Mon, 6 May 2024 14:12:52 +0200 Subject: [PATCH] chore: The slice test encounters a weird error that looks like rust is doing something weird ---- sharedptr::tests::slice stdout ---- thread 'sharedptr::tests::slice' panicked at src/allocator.rs:106:9: assertion `left == right` failed left: true right: true note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace --- src/sharedptr.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sharedptr.rs b/src/sharedptr.rs index 5c70540..88ce0b1 100644 --- a/src/sharedptr.rs +++ b/src/sharedptr.rs @@ -7,9 +7,9 @@ use std::{ use crate::allocator::ALLOCATOR; #[derive(Debug)] -pub struct SharedPtr<'a, const N: usize>(&'a mut [u8; N]); +pub struct SharedPtr([u8; N]); -impl SharedPtr<'_, N> { +impl SharedPtr { pub fn new() -> Option { let mut allocator = ALLOCATOR.lock().unwrap(); @@ -28,7 +28,7 @@ impl SharedPtr<'_, N> { } } -impl<'a, const N: usize> Deref for SharedPtr<'a, N> { +impl Deref for SharedPtr { type Target = [u8; N]; fn deref(&self) -> &Self::Target { @@ -36,13 +36,13 @@ impl<'a, const N: usize> Deref for SharedPtr<'a, N> { } } -impl<'a, const N: usize> DerefMut for SharedPtr<'a, N> { +impl<'a, const N: usize> DerefMut for SharedPtr { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl Drop for SharedPtr<'_, N> { +impl Drop for SharedPtr { fn drop(&mut self) { let mut allocator = ALLOCATOR.lock().unwrap();