@@ -212,66 +212,6 @@ impl<T:Copy> Cell<T> {
212
212
pub fn get ( & self ) -> T {
213
213
unsafe { * self . value . get ( ) }
214
214
}
215
-
216
- /// Returns a reference to the underlying `UnsafeCell`.
217
- ///
218
- /// # Examples
219
- ///
220
- /// ```
221
- /// #![feature(as_unsafe_cell)]
222
- ///
223
- /// use std::cell::Cell;
224
- ///
225
- /// let c = Cell::new(5);
226
- ///
227
- /// let uc = c.as_unsafe_cell();
228
- /// ```
229
- #[ inline]
230
- #[ unstable( feature = "as_unsafe_cell" , issue = "27708" ) ]
231
- #[ rustc_deprecated( since = "1.12.0" , reason = "renamed to as_ptr" ) ]
232
- pub fn as_unsafe_cell ( & self ) -> & UnsafeCell < T > {
233
- & self . value
234
- }
235
-
236
- /// Returns a raw pointer to the underlying data in this cell.
237
- ///
238
- /// # Examples
239
- ///
240
- /// ```
241
- /// use std::cell::Cell;
242
- ///
243
- /// let c = Cell::new(5);
244
- ///
245
- /// let ptr = c.as_ptr();
246
- /// ```
247
- #[ inline]
248
- #[ stable( feature = "cell_as_ptr" , since = "1.12.0" ) ]
249
- pub fn as_ptr ( & self ) -> * mut T {
250
- self . value . get ( )
251
- }
252
-
253
- /// Returns a mutable reference to the underlying data.
254
- ///
255
- /// This call borrows `Cell` mutably (at compile-time) which guarantees
256
- /// that we possess the only reference.
257
- ///
258
- /// # Examples
259
- ///
260
- /// ```
261
- /// use std::cell::Cell;
262
- ///
263
- /// let mut c = Cell::new(5);
264
- /// *c.get_mut() += 1;
265
- ///
266
- /// assert_eq!(c.get(), 6);
267
- /// ```
268
- #[ inline]
269
- #[ stable( feature = "cell_get_mut" , since = "1.11.0" ) ]
270
- pub fn get_mut ( & mut self ) -> & mut T {
271
- unsafe {
272
- & mut * self . value . get ( )
273
- }
274
- }
275
215
}
276
216
277
217
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -369,6 +309,66 @@ impl<T> Cell<T> {
369
309
}
370
310
}
371
311
312
+ /// Returns a reference to the underlying `UnsafeCell`.
313
+ ///
314
+ /// # Examples
315
+ ///
316
+ /// ```
317
+ /// #![feature(as_unsafe_cell)]
318
+ ///
319
+ /// use std::cell::Cell;
320
+ ///
321
+ /// let c = Cell::new(5);
322
+ ///
323
+ /// let uc = c.as_unsafe_cell();
324
+ /// ```
325
+ #[ inline]
326
+ #[ unstable( feature = "as_unsafe_cell" , issue = "27708" ) ]
327
+ #[ rustc_deprecated( since = "1.12.0" , reason = "renamed to as_ptr" ) ]
328
+ pub fn as_unsafe_cell ( & self ) -> & UnsafeCell < T > {
329
+ & self . value
330
+ }
331
+
332
+ /// Returns a raw pointer to the underlying data in this cell.
333
+ ///
334
+ /// # Examples
335
+ ///
336
+ /// ```
337
+ /// use std::cell::Cell;
338
+ ///
339
+ /// let c = Cell::new(5);
340
+ ///
341
+ /// let ptr = c.as_ptr();
342
+ /// ```
343
+ #[ inline]
344
+ #[ stable( feature = "cell_as_ptr" , since = "1.12.0" ) ]
345
+ pub fn as_ptr ( & self ) -> * mut T {
346
+ self . value . get ( )
347
+ }
348
+
349
+ /// Returns a mutable reference to the underlying data.
350
+ ///
351
+ /// This call borrows `Cell` mutably (at compile-time) which guarantees
352
+ /// that we possess the only reference.
353
+ ///
354
+ /// # Examples
355
+ ///
356
+ /// ```
357
+ /// use std::cell::Cell;
358
+ ///
359
+ /// let mut c = Cell::new(5);
360
+ /// *c.get_mut() += 1;
361
+ ///
362
+ /// assert_eq!(c.get(), 6);
363
+ /// ```
364
+ #[ inline]
365
+ #[ stable( feature = "cell_get_mut" , since = "1.11.0" ) ]
366
+ pub fn get_mut ( & mut self ) -> & mut T {
367
+ unsafe {
368
+ & mut * self . value . get ( )
369
+ }
370
+ }
371
+
372
372
/// Sets the contained value.
373
373
///
374
374
/// # Examples
0 commit comments