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
This commit is contained in:
@@ -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<const N: usize>([u8; N]);
|
||||
|
||||
impl<const N: usize> SharedPtr<'_, N> {
|
||||
impl<const N: usize> SharedPtr<N> {
|
||||
pub fn new() -> Option<Self> {
|
||||
let mut allocator = ALLOCATOR.lock().unwrap();
|
||||
|
||||
@@ -28,7 +28,7 @@ impl<const N: usize> SharedPtr<'_, N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, const N: usize> Deref for SharedPtr<'a, N> {
|
||||
impl<const N: usize> Deref for SharedPtr<N> {
|
||||
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<N> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<const N: usize> Drop for SharedPtr<'_, N> {
|
||||
impl<const N: usize> Drop for SharedPtr<N> {
|
||||
fn drop(&mut self) {
|
||||
let mut allocator = ALLOCATOR.lock().unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user