Skip to content

Commit 9ad17b9

Browse files
committed
tidy up
1 parent fdc2d1f commit 9ad17b9

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

library/alloc/src/sync.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -329,25 +329,25 @@ impl<T> Arc<T> {
329329
}
330330

331331
/// 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+
/// ```
351351
#[inline]
352352
#[unstable(feature = "arc_new_cyclic", issue = "none")]
353353
pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> T) -> Arc<T> {
@@ -358,7 +358,7 @@ impl<T> Arc<T> {
358358
weak: atomic::AtomicUsize::new(1),
359359
data: mem::MaybeUninit::<T>::uninit(),
360360
})
361-
.into();
361+
.into();
362362
let init_ptr: NonNull<ArcInner<T>> = uninit_ptr.cast();
363363

364364
let weak = Weak { ptr: init_ptr };
@@ -1683,9 +1683,9 @@ impl<T: ?Sized> Weak<T> {
16831683
}
16841684

16851685
// 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.
16891689
match inner.strong.compare_exchange_weak(n, n + 1, Acquire, Relaxed) {
16901690
Ok(_) => return Some(Arc::from_inner(self.ptr)), // null checked above
16911691
Err(old) => n = old,

0 commit comments

Comments
 (0)