@@ -213,66 +213,6 @@ impl<T:Copy> Cell<T> {
213213 pub fn get ( & self ) -> T {
214214 unsafe { * self . value . get ( ) }
215215 }
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- }
276216}
277217
278218#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -290,7 +230,7 @@ impl<T:Copy> Clone for Cell<T> {
290230}
291231
292232#[ stable( feature = "rust1" , since = "1.0.0" ) ]
293- impl < T : Default + Copy > Default for Cell < T > {
233+ impl < T : Default > Default for Cell < T > {
294234 /// Creates a `Cell<T>`, with the `Default` value for T.
295235 #[ inline]
296236 fn default ( ) -> Cell < T > {
@@ -346,7 +286,7 @@ impl<T:Ord + Copy> Ord for Cell<T> {
346286}
347287
348288#[ 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 > {
350290 fn from ( t : T ) -> Cell < T > {
351291 Cell :: new ( t)
352292 }
@@ -370,6 +310,66 @@ impl<T> Cell<T> {
370310 }
371311 }
372312
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+
373373 /// Sets the contained value.
374374 ///
375375 /// # Examples
0 commit comments