Skip to content

Commit 16b1793

Browse files
authored
Unrolled build for #143341
Rollup merge of #143341 - Manishearth:from-raw-parts-ptr-cast, r=samueltardieu Mention that casting to *const () is a way to roundtrip with from_raw_parts See discussion on #81513
2 parents 269d5b5 + 3ddd2ef commit 16b1793

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/core/src/ptr/metadata.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ pub const fn metadata<T: PointeeSized>(ptr: *const T) -> <T as Pointee>::Metadat
106106
/// For slices, see the documentation of [`slice::from_raw_parts`] for safety requirements.
107107
/// For trait objects, the metadata must come from a pointer to the same underlying erased type.
108108
///
109+
/// If you are attempting to deconstruct a DST in a generic context to be reconstructed later,
110+
/// a thin pointer can always be obtained by casting `*const T` to `*const ()`.
111+
///
109112
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
110113
#[unstable(feature = "ptr_metadata", issue = "81513")]
111114
#[inline]

0 commit comments

Comments
 (0)