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