148
148
//! ```
149
149
150
150
#![ stable( feature = "rust1" , since = "1.0.0" ) ]
151
+
152
+ use core:: prelude:: * ;
153
+
151
154
#[ cfg( not( test) ) ]
152
- use boxed;
155
+ use boxed:: Box ;
153
156
#[ cfg( test) ]
154
- use std:: boxed;
157
+ use std:: boxed:: Box ;
158
+
155
159
use core:: cell:: Cell ;
156
- use core:: clone:: Clone ;
157
- use core:: cmp:: { PartialEq , PartialOrd , Eq , Ord , Ordering } ;
158
- use core:: default:: Default ;
160
+ use core:: cmp:: Ordering ;
159
161
use core:: fmt;
160
162
use core:: hash:: { Hasher , Hash } ;
161
163
use core:: intrinsics:: { assume, drop_in_place} ;
162
- use core:: marker:: { self , Sized , Unsize } ;
164
+ use core:: marker:: { self , Unsize } ;
163
165
use core:: mem:: { self , min_align_of, size_of, min_align_of_val, size_of_val, forget} ;
164
166
use core:: nonzero:: NonZero ;
165
- use core:: ops:: { CoerceUnsized , Deref , Drop } ;
166
- use core:: option:: Option ;
167
- use core:: option:: Option :: { Some , None } ;
167
+ use core:: ops:: { CoerceUnsized , Deref } ;
168
168
use core:: ptr;
169
- use core:: result:: Result ;
170
- use core:: result:: Result :: { Ok , Err } ;
171
169
172
170
use heap:: deallocate;
173
171
@@ -212,7 +210,7 @@ impl<T> Rc<T> {
212
210
// pointers, which ensures that the weak destructor never frees
213
211
// the allocation while the strong destructor is running, even
214
212
// if the weak pointer is stored inside the strong one.
215
- _ptr : NonZero :: new ( boxed :: into_raw ( box RcBox {
213
+ _ptr : NonZero :: new ( Box :: into_raw ( box RcBox {
216
214
strong : Cell :: new ( 1 ) ,
217
215
weak : Cell :: new ( 1 ) ,
218
216
value : value
@@ -230,14 +228,14 @@ impl<T> Rc<T> {
230
228
///
231
229
/// ```
232
230
/// # #![feature(rc_unique)]
233
- /// use std::rc::{self, Rc} ;
231
+ /// use std::rc::Rc ;
234
232
///
235
233
/// let x = Rc::new(3);
236
- /// assert_eq!(rc ::try_unwrap(x), Ok(3));
234
+ /// assert_eq!(Rc ::try_unwrap(x), Ok(3));
237
235
///
238
236
/// let x = Rc::new(4);
239
237
/// let _y = x.clone();
240
- /// assert_eq!(rc ::try_unwrap(x), Err(Rc::new(4)));
238
+ /// assert_eq!(Rc ::try_unwrap(x), Err(Rc::new(4)));
241
239
/// ```
242
240
#[ inline]
243
241
#[ unstable( feature = "rc_unique" ) ]
@@ -295,17 +293,16 @@ impl<T: ?Sized> Rc<T> {
295
293
///
296
294
/// ```
297
295
/// # #![feature(rc_unique)]
298
- /// use std::rc;
299
296
/// use std::rc::Rc;
300
297
///
301
298
/// let five = Rc::new(5);
302
299
///
303
- /// rc ::is_unique(&five);
300
+ /// assert!(Rc ::is_unique(&five) );
304
301
/// ```
305
302
#[ inline]
306
303
#[ unstable( feature = "rc_unique" ) ]
307
304
pub fn is_unique ( rc : & Rc < T > ) -> bool {
308
- weak_count ( rc) == 0 && strong_count ( rc) == 1
305
+ Rc :: weak_count ( rc) == 0 && Rc :: strong_count ( rc) == 1
309
306
}
310
307
311
308
/// Returns a mutable reference to the contained value if the `Rc<T>` is
@@ -317,14 +314,14 @@ impl<T: ?Sized> Rc<T> {
317
314
///
318
315
/// ```
319
316
/// # #![feature(rc_unique)]
320
- /// use std::rc::{self, Rc} ;
317
+ /// use std::rc::Rc ;
321
318
///
322
319
/// let mut x = Rc::new(3);
323
- /// *rc ::get_mut(&mut x).unwrap() = 4;
320
+ /// *Rc ::get_mut(&mut x).unwrap() = 4;
324
321
/// assert_eq!(*x, 4);
325
322
///
326
323
/// let _y = x.clone();
327
- /// assert!(rc ::get_mut(&mut x).is_none());
324
+ /// assert!(Rc ::get_mut(&mut x).is_none());
328
325
/// ```
329
326
#[ inline]
330
327
#[ unstable( feature = "rc_unique" ) ]
@@ -432,7 +429,7 @@ impl<T: Clone> Rc<T> {
432
429
#[ inline]
433
430
#[ unstable( feature = "rc_unique" ) ]
434
431
pub fn make_unique ( & mut self ) -> & mut T {
435
- if !is_unique ( self ) {
432
+ if !Rc :: is_unique ( self ) {
436
433
* self = Rc :: new ( ( * * self ) . clone ( ) )
437
434
}
438
435
// This unsafety is ok because we're guaranteed that the pointer
0 commit comments