From: Ian Jackson Date: Sat, 16 Nov 2024 19:14:01 +0000 (+0000) Subject: docs X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;p=manually-boxed docs --- diff --git a/src/lib.rs b/src/lib.rs index 3545f96..013a144 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,6 +77,7 @@ use std::ptr::NonNull; /// `Ptr` usually refers to an item on the heap, like `Box`. /// It can be made from `T` with [`Ptr::new_heap()`], /// or [`From`](#impl-From%3CBox%3CT%3E%3E-for-Ptr%3CT%3E). +/// It is then freed again with [`.free_heap()`](Ptr::free_heap). /// /// To access the contained data use, /// [`Ptr::borrow()`] @@ -357,9 +358,12 @@ impl Ptr { /// Frees a `Ptr` that was made with `new_heap` /// + /// The contained `T` is dropped. + /// To keep it, use [`.free_heap_return()`](Ptr::free_heap_return). + /// /// # SAFETY /// - /// `self` must have come from `new_heap`, + /// `self` must have come from `new_heap` (or `From`) /// and be the only remaining copy of this `Ptr` /// (or the only one which will be used). /// @@ -376,6 +380,10 @@ impl Ptr { /// Frees a `Ptr` that was made with `new_heap` and returns the `T` /// + /// If `T` is not `Sized`, + /// you must use [`free_heap`](Ptr::free_heap) (discarding `T`) + /// or [`into_box`](Ptr::into_box) (leaving it on the heap). + /// /// # SAFETY /// /// The same rules as [`free_heap`](Ptr::free_heap) apply.