File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -528,6 +528,7 @@ impl<T> Arc<T> {
528
528
///
529
529
/// # Examples
530
530
///
531
+ /// Minimal example demonstrating the guarantee that `unwrap_or_drop` gives.
531
532
/// ```
532
533
/// #![feature(unwrap_or_drop)]
533
534
///
@@ -548,11 +549,17 @@ impl<T> Arc<T> {
548
549
/// (x_unwrapped_value, y_unwrapped_value),
549
550
/// (None, Some(3)) | (Some(3), None)
550
551
/// ));
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
+ /// ```
551
555
///
556
+ /// A more practical example demonstrating the need for `unwrap_or_drop`:
557
+ /// ```
558
+ /// #![feature(unwrap_or_drop)]
552
559
///
560
+ /// use std::sync::Arc;
553
561
///
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`:
556
563
/// #[derive(Clone)]
557
564
/// struct LinkedList<T>(Option<Arc<Node<T>>>);
558
565
/// struct Node<T>(T, Option<Arc<Node<T>>>);
You can’t perform that action at this time.
0 commit comments