From 62ae34863c7a9e03c16b0e2db65de5b12f2d34ee Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 14 Nov 2024 22:33:50 +0000 Subject: [PATCH] unsized --- src/lib.rs | 2 +- src/test.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index bae5e82..7be9207 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ use std::ptr::NonNull; /// /// Ensuring that `Ptr`s are freed at the right time is up to the caller. /// But aliasing, drop, etc., is (largely) handled by the library. -pub struct Ptr { +pub struct Ptr { /// # SAFETY /// /// Invariants (only while valid, but we can rely on them diff --git a/src/test.rs b/src/test.rs index eba2cd4..996db00 100644 --- a/src/test.rs +++ b/src/test.rs @@ -41,3 +41,11 @@ fn demo() { drop(l); } + +#[test] +fn unsize() { + let mut noalias = unsafe { NoAliasSingleton::init() }; + let p = Ptr::new_heap("hi"); + println!("{}", p.borrow(&noalias)); + unsafe { p.free_heap(&mut noalias) }; +} -- 2.30.2