@@ -163,11 +163,13 @@ use option::{None, Option, Some};
163163use ty:: Unsafe ;
164164
165165/// A mutable memory location that admits only `Copy` data.
166+ #[ unstable = "likely to be renamed; otherwise stable" ]
166167pub struct Cell < T > {
167168 value : Unsafe < T > ,
168169 noshare : marker:: NoShare ,
169170}
170171
172+ #[ stable]
171173impl < T : Copy > Cell < T > {
172174 /// Creates a new `Cell` containing the given value.
173175 pub fn new ( value : T ) -> Cell < T > {
@@ -192,20 +194,22 @@ impl<T:Copy> Cell<T> {
192194 }
193195}
194196
195- #[ unstable]
197+ #[ unstable = "waiting for `Clone` trait to become stable" ]
196198impl < T : Copy > Clone for Cell < T > {
197199 fn clone ( & self ) -> Cell < T > {
198200 Cell :: new ( self . get ( ) )
199201 }
200202}
201203
204+ #[ unstable = "waiting for `PartialEq` trait to become stable" ]
202205impl < T : PartialEq + Copy > PartialEq for Cell < T > {
203206 fn eq ( & self , other : & Cell < T > ) -> bool {
204207 self . get ( ) == other. get ( )
205208 }
206209}
207210
208211/// A mutable memory location with dynamically checked borrow rules
212+ #[ unstable = "likely to be renamed; otherwise stable" ]
209213pub struct RefCell < T > {
210214 value : Unsafe < T > ,
211215 borrow : Cell < BorrowFlag > ,
@@ -221,6 +225,7 @@ static WRITING: BorrowFlag = -1;
221225
222226impl < T > RefCell < T > {
223227 /// Create a new `RefCell` containing `value`
228+ #[ stable]
224229 pub fn new ( value : T ) -> RefCell < T > {
225230 RefCell {
226231 value : Unsafe :: new ( value) ,
@@ -231,6 +236,7 @@ impl<T> RefCell<T> {
231236 }
232237
233238 /// Consumes the `RefCell`, returning the wrapped value.
239+ #[ unstable = "may be renamed, depending on global conventions" ]
234240 pub fn unwrap ( self ) -> T {
235241 debug_assert ! ( self . borrow. get( ) == UNUSED ) ;
236242 unsafe { self . value . unwrap ( ) }
@@ -242,6 +248,7 @@ impl<T> RefCell<T> {
242248 /// immutable borrows can be taken out at the same time.
243249 ///
244250 /// Returns `None` if the value is currently mutably borrowed.
251+ #[ unstable = "may be renamed, depending on global conventions" ]
245252 pub fn try_borrow < ' a > ( & ' a self ) -> Option < Ref < ' a , T > > {
246253 match self . borrow . get ( ) {
247254 WRITING => None ,
@@ -260,6 +267,7 @@ impl<T> RefCell<T> {
260267 /// # Failure
261268 ///
262269 /// Fails if the value is currently mutably borrowed.
270+ #[ unstable]
263271 pub fn borrow < ' a > ( & ' a self ) -> Ref < ' a , T > {
264272 match self . try_borrow ( ) {
265273 Some ( ptr) => ptr,
@@ -273,6 +281,7 @@ impl<T> RefCell<T> {
273281 /// cannot be borrowed while this borrow is active.
274282 ///
275283 /// Returns `None` if the value is currently borrowed.
284+ #[ unstable = "may be renamed, depending on global conventions" ]
276285 pub fn try_borrow_mut < ' a > ( & ' a self ) -> Option < RefMut < ' a , T > > {
277286 match self . borrow . get ( ) {
278287 UNUSED => {
@@ -291,6 +300,7 @@ impl<T> RefCell<T> {
291300 /// # Failure
292301 ///
293302 /// Fails if the value is currently borrowed.
303+ #[ unstable]
294304 pub fn borrow_mut < ' a > ( & ' a self ) -> RefMut < ' a , T > {
295305 match self . try_borrow_mut ( ) {
296306 Some ( ptr) => ptr,
@@ -299,27 +309,30 @@ impl<T> RefCell<T> {
299309 }
300310}
301311
302- #[ unstable]
312+ #[ unstable = "waiting for `Clone` to become stable" ]
303313impl < T : Clone > Clone for RefCell < T > {
304314 fn clone ( & self ) -> RefCell < T > {
305315 RefCell :: new ( self . borrow ( ) . clone ( ) )
306316 }
307317}
308318
319+ #[ unstable = "waiting for `PartialEq` to become stable" ]
309320impl < T : PartialEq > PartialEq for RefCell < T > {
310321 fn eq ( & self , other : & RefCell < T > ) -> bool {
311322 * self . borrow ( ) == * other. borrow ( )
312323 }
313324}
314325
315326/// Wraps a borrowed reference to a value in a `RefCell` box.
327+ #[ unstable]
316328pub struct Ref < ' b , T > {
317329 // FIXME #12808: strange name to try to avoid interfering with
318330 // field accesses of the contained type via Deref
319331 _parent : & ' b RefCell < T >
320332}
321333
322334#[ unsafe_destructor]
335+ #[ unstable]
323336impl < ' b , T > Drop for Ref < ' b , T > {
324337 fn drop ( & mut self ) {
325338 let borrow = self . _parent . borrow . get ( ) ;
@@ -328,6 +341,7 @@ impl<'b, T> Drop for Ref<'b, T> {
328341 }
329342}
330343
344+ #[ unstable = "waiting for `Deref` to become stable" ]
331345impl < ' b , T > Deref < T > for Ref < ' b , T > {
332346 #[ inline]
333347 fn deref < ' a > ( & ' a self ) -> & ' a T {
@@ -341,7 +355,7 @@ impl<'b, T> Deref<T> for Ref<'b, T> {
341355///
342356/// A `Clone` implementation would interfere with the widespread
343357/// use of `r.borrow().clone()` to clone the contents of a `RefCell`.
344- #[ experimental]
358+ #[ experimental = "likely to be moved to a method, pending language changes" ]
345359pub fn clone_ref < ' b , T > ( orig : & Ref < ' b , T > ) -> Ref < ' b , T > {
346360 // Since this Ref exists, we know the borrow flag
347361 // is not set to WRITING.
@@ -355,13 +369,15 @@ pub fn clone_ref<'b, T>(orig: &Ref<'b, T>) -> Ref<'b, T> {
355369}
356370
357371/// Wraps a mutable borrowed reference to a value in a `RefCell` box.
372+ #[ unstable]
358373pub struct RefMut < ' b , T > {
359374 // FIXME #12808: strange name to try to avoid interfering with
360375 // field accesses of the contained type via Deref
361376 _parent : & ' b RefCell < T >
362377}
363378
364379#[ unsafe_destructor]
380+ #[ unstable]
365381impl < ' b , T > Drop for RefMut < ' b , T > {
366382 fn drop ( & mut self ) {
367383 let borrow = self . _parent . borrow . get ( ) ;
@@ -370,13 +386,15 @@ impl<'b, T> Drop for RefMut<'b, T> {
370386 }
371387}
372388
389+ #[ unstable = "waiting for `Deref` to become stable" ]
373390impl < ' b , T > Deref < T > for RefMut < ' b , T > {
374391 #[ inline]
375392 fn deref < ' a > ( & ' a self ) -> & ' a T {
376393 unsafe { & * self . _parent . value . get ( ) }
377394 }
378395}
379396
397+ #[ unstable = "waiting for `DerefMut` to become stable" ]
380398impl < ' b , T > DerefMut < T > for RefMut < ' b , T > {
381399 #[ inline]
382400 fn deref_mut < ' a > ( & ' a mut self ) -> & ' a mut T {
0 commit comments