Skip to content

Commit 838e5ed

Browse files
committed
split examples
1 parent 1ceee61 commit 838e5ed

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
@@ -528,6 +528,7 @@ impl<T> Arc<T> {
528528
///
529529
/// # Examples
530530
///
531+
/// Minimal example demonstrating the guarantee that `unwrap_or_drop` gives.
531532
/// ```
532533
/// #![feature(unwrap_or_drop)]
533534
///
@@ -548,11 +549,17 @@ impl<T> Arc<T> {
548549
/// (x_unwrapped_value, y_unwrapped_value),
549550
/// (None, Some(3)) | (Some(3), None)
550551
/// ));
552+
/// // The result could also be `(None, None)` if the threads called
553+
/// // `Arc::try_unwrap(x).ok()` and `Arc::try_unwrap(y).ok()` instead.
554+
/// ```
551555
///
556+
/// A more practical example demonstrating the need for `unwrap_or_drop`:
557+
/// ```
558+
/// #![feature(unwrap_or_drop)]
552559
///
560+
/// use std::sync::Arc;
553561
///
554-
/// // For a somewhat more practical example,
555-
/// // we define a singly linked list using `Arc`:
562+
/// // Definition of a simple singly linked list using `Arc`:
556563
/// #[derive(Clone)]
557564
/// struct LinkedList<T>(Option<Arc<Node<T>>>);
558565
/// struct Node<T>(T, Option<Arc<Node<T>>>);

0 commit comments

Comments
 (0)