Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c02bdc

Browse files
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 e420e45 + 3ddd2ef commit 0c02bdc

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)

AltStyle によって変換されたページ (->オリジナル) /