/rust/registry/src/index.crates.io-1949cf8c6b5b557f/seize-0.5.1/src/reclaim.rs
Line | Count | Source |
1 | | //! Common memory reclaimers. |
2 | | //! |
3 | | //! The functions in this module can be passed to |
4 | | //! [`retire`](crate::Collector::retire) to free allocated memory or run drop |
5 | | //! glue. See [the guide](crate#custom-reclaimers) for details about memory |
6 | | //! reclamation, and writing custom reclaimers. |
7 | | |
8 | | use std::ptr; |
9 | | |
10 | | use crate::Collector; |
11 | | |
12 | | /// Reclaims memory allocated with [`Box`]. |
13 | | /// |
14 | | /// # Safety |
15 | | /// |
16 | | /// The safety requirements of [`Box::from_raw`] apply. |
17 | 0 | pub unsafe fn boxed<T>(ptr: *mut T, _collector: &Collector) { |
18 | 0 | unsafe { drop(Box::from_raw(ptr)) } |
19 | 0 | } Unexecuted instantiation: seize::reclaim::boxed::<papaya::raw::Entry<bytes::bytes::Bytes, ()>> Unexecuted instantiation: seize::reclaim::boxed::<_> |
20 | | |
21 | | /// Reclaims memory by dropping the value in place. |
22 | | /// |
23 | | /// # Safety |
24 | | /// |
25 | | /// The safety requirements of [`ptr::drop_in_place`] apply. |
26 | 0 | pub unsafe fn in_place<T>(ptr: *mut T, _collector: &Collector) { |
27 | 0 | unsafe { ptr::drop_in_place::<T>(ptr) } |
28 | 0 | } |