diff options
| author | DPC <dylan.dpc@gmail.com> | 2020-08-15 03:16:20 +0200 |
|---|---|---|
| committer | DPC <dylan.dpc@gmail.com> | 2020-08-15 03:16:20 +0200 |
| commit | 9ad17b9ca7a0fce32abf4c85ee38ed14aefe39cf (patch) | |
| tree | df719216c2b0814ffe0ae124094a3a567e1cc887 | |
| parent | fdc2d1f49906752585177e99b8bc285d796e4b3e (diff) | |
| download | rust-9ad17b9ca7a0fce32abf4c85ee38ed14aefe39cf.tar.gz rust-9ad17b9ca7a0fce32abf4c85ee38ed14aefe39cf.zip | |
tidy up
| -rw-r--r-- | library/alloc/src/sync.rs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 45852aa41f9..4ac7dc4d890 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -329,25 +329,25 @@ impl<T> Arc<T> { } /// Constructs a new `Arc<T>` using a weak reference to itself. Attempting - /// to upgrade the weak reference before this function returns will result - /// in a `None` value. However, the weak reference may be cloned freely and - /// stored for use at a later time. - /// - /// # Examples - /// ``` - /// #![feature(arc_new_cyclic)] - /// #![allow(dead_code)] - /// - /// use std::sync::{Arc, Weak}; - /// - /// struct Foo { - /// me: Weak<Foo>, - /// } - /// - /// let foo = Arc::new_cyclic(|me| Foo { - /// me: me.clone(), - /// }); - /// ``` + /// to upgrade the weak reference before this function returns will result + /// in a `None` value. However, the weak reference may be cloned freely and + /// stored for use at a later time. + /// + /// # Examples + /// ``` + /// #![feature(arc_new_cyclic)] + /// #![allow(dead_code)] + /// + /// use std::sync::{Arc, Weak}; + /// + /// struct Foo { + /// me: Weak<Foo>, + /// } + /// + /// let foo = Arc::new_cyclic(|me| Foo { + /// me: me.clone(), + /// }); + /// ``` #[inline] #[unstable(feature = "arc_new_cyclic", issue = "none")] pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> T) -> Arc<T> { @@ -358,7 +358,7 @@ impl<T> Arc<T> { weak: atomic::AtomicUsize::new(1), data: mem::MaybeUninit::<T>::uninit(), }) - .into(); + .into(); let init_ptr: NonNull<ArcInner<T>> = uninit_ptr.cast(); let weak = Weak { ptr: init_ptr }; @@ -1683,9 +1683,9 @@ impl<T: ?Sized> Weak<T> { } // Relaxed is fine for the failure case because we don't have any expectations about the new state. - // Acquire is necessary for the success case to synchronise with `Arc::new_cyclic`, when the inner - // value can be initialized after `Weak` references have already been created. In that case, we - // expect to observe the fully initialized value. + // Acquire is necessary for the success case to synchronise with `Arc::new_cyclic`, when the inner + // value can be initialized after `Weak` references have already been created. In that case, we + // expect to observe the fully initialized value. match inner.strong.compare_exchange_weak(n, n + 1, Acquire, Relaxed) { Ok(_) => return Some(Arc::from_inner(self.ptr)), // null checked above Err(old) => n = old, |
