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 @@ -544,6 +544,7 @@ impl<T> Arc<T> {
544
544
///
545
545
/// # Examples
546
546
///
547
+ /// Minimal example demonstrating the guarantee that `unwrap_or_drop` gives.
547
548
/// ```
548
549
/// #![feature(unwrap_or_drop)]
549
550
///
@@ -564,11 +565,17 @@ impl<T> Arc<T> {
564
565
/// (x_unwrapped_value, y_unwrapped_value),
565
566
/// (None, Some(3)) | (Some(3), None)
566
567
/// ));
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
+ /// ```
567
571
///
572
+ /// A more practical example demonstrating the need for `unwrap_or_drop`:
573
+ /// ```
574
+ /// #![feature(unwrap_or_drop)]
568
575
///
576
+ /// use std::sync::Arc;
569
577
///
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`:
572
579
/// #[derive(Clone)]
573
580
/// struct LinkedList<T>(Option<Arc<Node<T>>>);
574
581
/// struct Node<T>(T, Option<Arc<Node<T>>>);
You can’t perform that action at this time.
0 commit comments