Skip to content

Commit fbedcd5

Browse files
committed
split examples
1 parent a0740b8 commit fbedcd5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

library/alloc/src/sync.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ impl<T> Arc<T> {
544544
///
545545
/// # Examples
546546
///
547+
/// Minimal example demonstrating the guarantee that `unwrap_or_drop` gives.
547548
/// ```
548549
/// #![feature(unwrap_or_drop)]
549550
///
@@ -564,11 +565,17 @@ impl<T> Arc<T> {
564565
/// (x_unwrapped_value, y_unwrapped_value),
565566
/// (None, Some(3)) | (Some(3), None)
566567
/// ));
568+
/// // The result could also be `(None, None)` if the threads called
569+
/// // `Arc::try_unwrap(x).ok()` and `Arc::try_unwrap(y).ok()` instead.
570+
/// ```
567571
///
572+
/// A more practical example demonstrating the need for `unwrap_or_drop`:
573+
/// ```
574+
/// #![feature(unwrap_or_drop)]
568575
///
576+
/// use std::sync::Arc;
569577
///
570-
/// // For a somewhat more practical example,
571-
/// // we define a singly linked list using `Arc`:
578+
/// // Definition of a simple singly linked list using `Arc`:
572579
/// #[derive(Clone)]
573580
/// struct LinkedList<T>(Option<Arc<Node<T>>>);
574581
/// struct Node<T>(T, Option<Arc<Node<T>>>);

0 commit comments

Comments
 (0)