From: Ian Jackson Date: Thu, 14 Nov 2024 23:40:05 +0000 (+0000) Subject: docs etc. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=c7c0350f6a85dad15b82faf443caa76d11251add;p=manually-boxed docs etc. --- diff --git a/src/lib.rs b/src/lib.rs index 8124c38..86e38f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,7 +77,7 @@ use std::ptr::NonNull; /// It can be made from `T` with [`Ptr::new_heap()`], /// or [`From`](#impl-From%3CBox%3CT%3E%3E-for-Ptr%3CT%3E). /// -/// To access the contained data, +/// To access the contained data use, /// [`Ptr::borrow()`] /// and /// [`borrow_mut()`](Ptr::borrow_mut). @@ -309,14 +309,11 @@ impl Ptr { /// (or the only one which will be used). /// /// All copies of `self` will be invalidated. - /// - /// So either no copies may exist any longer, - /// or it is your responsibility to ensure + /// It is your responsibility to ensure /// that none of them will be used. + /// ("used" means passed to any method in this library.) /// - /// ("used" means passed to any method in this library). - /// - /// (The compiler will check that no borrows are live.) + /// The compiler will check that no borrows are live. #[inline] pub unsafe fn free_heap<'a>(self, tok: impl IsMutToken<'a>) { let _t: Box = unsafe { self.into_box(tok) }; @@ -328,7 +325,7 @@ impl Ptr { /// /// The same rules as [`free_heap`](Ptr::free_heap) apply. #[inline] - pub unsafe fn from_heap<'a>(self, tok: impl IsMutToken<'a>) -> T + pub unsafe fn free_heap_return<'a>(self, tok: impl IsMutToken<'a>) -> T where T: Sized { let t: Box = unsafe { self.into_box(tok) }; diff --git a/src/test/demo.rs b/src/test/demo.rs index 7d9cff3..d99240d 100644 --- a/src/test/demo.rs +++ b/src/test/demo.rs @@ -139,7 +139,7 @@ impl List { } else { *tail = None; } - let deleted = unsafe { deleting.from_heap(&mut tok) }; + let deleted = unsafe { deleting.free_heap_return(&mut tok) }; Some(deleted.data) }