self as _
}
+ /// Decompose a (possibly wide) pointer into is address and metadata components.
+ ///
+ /// The pointer can be later reconstructed with [`from_raw_parts_mut`].
+ #[cfg(not(bootstrap))]
+ #[unstable(feature = "ptr_metadata", issue = "81513")]
+ #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
+ #[inline]
+ pub const fn to_raw_parts(self) -> (*mut (), <T as super::Pointee>::Metadata) {
+ (self.cast(), super::metadata(self))
+ }
+
/// Returns `None` if the pointer is null, or else returns a shared reference to
/// the value wrapped in `Some`. If the value may be uninitialized, [`as_uninit_ref`]
/// must be used instead.
}
/// Calculates the offset from a pointer using wrapping arithmetic.
- /// (convenience for `.wrapping_offset((count as isize).wrapping_sub())`)
+ /// (convenience for `.wrapping_offset((count as isize).wrapping_neg())`)
///
/// `count` is in units of T; e.g., a `count` of 3 represents a pointer
/// offset of `3 * size_of::<T>()` bytes.
#[unstable(feature = "slice_ptr_len", issue = "71146")]
#[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
pub const fn len(self) -> usize {
- // SAFETY: this is safe because `*const [T]` and `FatPtr<T>` have the same layout.
- // Only `std` can make this guarantee.
- unsafe { Repr { rust_mut: self }.raw }.len
+ #[cfg(bootstrap)]
+ {
+ // SAFETY: this is safe because `*const [T]` and `FatPtr<T>` have the same layout.
+ // Only `std` can make this guarantee.
+ unsafe { Repr { rust_mut: self }.raw }.len
+ }
+ #[cfg(not(bootstrap))]
+ metadata(self)
}
/// Returns a raw pointer to the slice's buffer.