chiark / gitweb /
docs etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Nov 2024 23:40:05 +0000 (23:40 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 14 Nov 2024 23:40:05 +0000 (23:40 +0000)
src/lib.rs
src/test/demo.rs

index 8124c383c5e38d809253bb03dba990ab93310f1c..86e38f5c678deb161975a575b67ab6279bac67de 100644 (file)
@@ -77,7 +77,7 @@ use std::ptr::NonNull;
 /// It can be made from `T` with [`Ptr::new_heap()`],
 /// or [`From<Box>`](#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<T: ?Sized> Ptr<T> {
     /// (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<T> = unsafe { self.into_box(tok) };
@@ -328,7 +325,7 @@ impl<T: ?Sized> Ptr<T> {
     ///
     /// 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<T> = unsafe { self.into_box(tok) };
index 7d9cff3261963a3067a2e55c20dbf19a915698fd..d99240d162dda117985736f53cf85649213c2b6f 100644 (file)
@@ -139,7 +139,7 @@ impl<T: Debug> List<T> {
         } else {
             *tail = None;
         }
-        let deleted = unsafe { deleting.from_heap(&mut tok) };
+        let deleted = unsafe { deleting.free_heap_return(&mut tok) };
         Some(deleted.data)
     }