about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-08-22 16:59:28 -0700
committerGitHub <noreply@github.com>2016-08-22 16:59:28 -0700
commitd0da7f6af9d8547376d9497042eb3f4e6013776d (patch)
tree07e2e49d871682a5ee73e2dfbc271de9ac02041a /src/liballoc
parent3c5a0fa45b5e2786b6e64e27f48cd129e7aefdbd (diff)
parent8ea29366597e1b4af9c215ce485df3b4a4a447de (diff)
downloadrust-d0da7f6af9d8547376d9497042eb3f4e6013776d.tar.gz
rust-d0da7f6af9d8547376d9497042eb3f4e6013776d.zip
Auto merge of #35908 - jonathandturner:rollup, r=jonathandturner
Rollup of 20 pull requests

- Successful merges: #35360, #35526, #35809, #35817, #35820, #35824, #35835, #35841, #35842, #35858, #35860, #35861, #35864, #35878, #35879, #35881, #35882, #35889, #35891, #35901
- Failed merges: #35395
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/rc.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 2beb652aa01..3a158240c3a 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -263,6 +263,23 @@ impl<T> Rc<T> {
     }
 
     /// Checks if `Rc::try_unwrap` would return `Ok`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// #![feature(rc_would_unwrap)]
+    ///
+    /// use std::rc::Rc;
+    ///
+    /// let x = Rc::new(3);
+    /// assert!(Rc::would_unwrap(&x));
+    /// assert_eq!(Rc::try_unwrap(x), Ok(3));
+    ///
+    /// let x = Rc::new(4);
+    /// let _y = x.clone();
+    /// assert!(!Rc::would_unwrap(&x));
+    /// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
+    /// ```
     #[unstable(feature = "rc_would_unwrap",
                reason = "just added for niche usecase",
                issue = "28356")]