@@ -329,25 +329,25 @@ impl<T> Arc<T> {
329
329
}
330
330
331
331
/// Constructs a new `Arc<T>` using a weak reference to itself. Attempting
332
- /// to upgrade the weak reference before this function returns will result
333
- /// in a `None` value. However, the weak reference may be cloned freely and
334
- /// stored for use at a later time.
335
- ///
336
- /// # Examples
337
- /// ```
338
- /// #![feature(arc_new_cyclic)]
339
- /// #![allow(dead_code)]
340
- ///
341
- /// use std::sync::{Arc, Weak};
342
- ///
343
- /// struct Foo {
344
- /// me: Weak<Foo>,
345
- /// }
346
- ///
347
- /// let foo = Arc::new_cyclic(|me| Foo {
348
- /// me: me.clone(),
349
- /// });
350
- /// ```
332
+ /// to upgrade the weak reference before this function returns will result
333
+ /// in a `None` value. However, the weak reference may be cloned freely and
334
+ /// stored for use at a later time.
335
+ ///
336
+ /// # Examples
337
+ /// ```
338
+ /// #![feature(arc_new_cyclic)]
339
+ /// #![allow(dead_code)]
340
+ ///
341
+ /// use std::sync::{Arc, Weak};
342
+ ///
343
+ /// struct Foo {
344
+ /// me: Weak<Foo>,
345
+ /// }
346
+ ///
347
+ /// let foo = Arc::new_cyclic(|me| Foo {
348
+ /// me: me.clone(),
349
+ /// });
350
+ /// ```
351
351
#[ inline]
352
352
#[ unstable( feature = "arc_new_cyclic" , issue = "none" ) ]
353
353
pub fn new_cyclic ( data_fn : impl FnOnce ( & Weak < T > ) -> T ) -> Arc < T > {
@@ -358,7 +358,7 @@ impl<T> Arc<T> {
358
358
weak : atomic:: AtomicUsize :: new ( 1 ) ,
359
359
data : mem:: MaybeUninit :: < T > :: uninit ( ) ,
360
360
} )
361
- . into ( ) ;
361
+ . into ( ) ;
362
362
let init_ptr: NonNull < ArcInner < T > > = uninit_ptr. cast ( ) ;
363
363
364
364
let weak = Weak { ptr : init_ptr } ;
@@ -1683,9 +1683,9 @@ impl<T: ?Sized> Weak<T> {
1683
1683
}
1684
1684
1685
1685
// Relaxed is fine for the failure case because we don't have any expectations about the new state.
1686
- // Acquire is necessary for the success case to synchronise with `Arc::new_cyclic`, when the inner
1687
- // value can be initialized after `Weak` references have already been created. In that case, we
1688
- // expect to observe the fully initialized value.
1686
+ // Acquire is necessary for the success case to synchronise with `Arc::new_cyclic`, when the inner
1687
+ // value can be initialized after `Weak` references have already been created. In that case, we
1688
+ // expect to observe the fully initialized value.
1689
1689
match inner. strong . compare_exchange_weak ( n, n + 1 , Acquire , Relaxed ) {
1690
1690
Ok ( _) => return Some ( Arc :: from_inner ( self . ptr ) ) , // null checked above
1691
1691
Err ( old) => n = old,
0 commit comments