@@ -117,72 +117,6 @@ impl<T: ?Sized> *mut T {
117117 self as _
118118 }
119119
120- /// Casts a pointer to its raw bits.
121- ///
122- /// This is equivalent to `as usize`, but is more specific to enhance readability.
123- /// The inverse method is [`from_bits`](pointer#method.from_bits-1).
124- ///
125- /// In particular, `*p as usize` and `p as usize` will both compile for
126- /// pointers to numeric types but do very different things, so using this
127- /// helps emphasize that reading the bits was intentional.
128- ///
129- /// # Examples
130- ///
131- /// ```
132- /// #![feature(ptr_to_from_bits)]
133- /// # #[cfg(not(miri))] { // doctest does not work with strict provenance
134- /// let mut array = [13, 42];
135- /// let mut it = array.iter_mut();
136- /// let p0: *mut i32 = it.next().unwrap();
137- /// assert_eq!(<*mut _>::from_bits(p0.to_bits()), p0);
138- /// let p1: *mut i32 = it.next().unwrap();
139- /// assert_eq!(p1.to_bits() - p0.to_bits(), 4);
140- /// }
141- /// ```
142- #[ unstable( feature = "ptr_to_from_bits" , issue = "91126" ) ]
143- #[ deprecated(
144- since = "1.67.0" ,
145- note = "replaced by the `expose_provenance` method, or update your code \
146- to follow the strict provenance rules using its APIs"
147- ) ]
148- #[ inline( always) ]
149- pub fn to_bits ( self ) -> usize
150- where
151- T : Sized ,
152- {
153- self as usize
154- }
155-
156- /// Creates a pointer from its raw bits.
157- ///
158- /// This is equivalent to `as *mut T`, but is more specific to enhance readability.
159- /// The inverse method is [`to_bits`](pointer#method.to_bits-1).
160- ///
161- /// # Examples
162- ///
163- /// ```
164- /// #![feature(ptr_to_from_bits)]
165- /// # #[cfg(not(miri))] { // doctest does not work with strict provenance
166- /// use std::ptr::NonNull;
167- /// let dangling: *mut u8 = NonNull::dangling().as_ptr();
168- /// assert_eq!(<*mut u8>::from_bits(1), dangling);
169- /// }
170- /// ```
171- #[ unstable( feature = "ptr_to_from_bits" , issue = "91126" ) ]
172- #[ deprecated(
173- since = "1.67.0" ,
174- note = "replaced by the `ptr::with_exposed_provenance_mut` function, or \
175- update your code to follow the strict provenance rules using its APIs"
176- ) ]
177- #[ allow( fuzzy_provenance_casts) ] // this is an unstable and semi-deprecated cast function
178- #[ inline( always) ]
179- pub fn from_bits ( bits : usize ) -> Self
180- where
181- T : Sized ,
182- {
183- bits as Self
184- }
185-
186120 /// Gets the "address" portion of the pointer.
187121 ///
188122 /// This is similar to `self as usize`, which semantically discards *provenance* and
0 commit comments