We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b560f5a + 5310d11 commit 375695cCopy full SHA for 375695c
src/liballoc/rc.rs
@@ -263,6 +263,23 @@ impl<T> Rc<T> {
263
}
264
265
/// Checks if `Rc::try_unwrap` would return `Ok`.
266
+ ///
267
+ /// # Examples
268
269
+ /// ```
270
+ /// #![feature(rc_would_unwrap)]
271
272
+ /// use std::rc::Rc;
273
274
+ /// let x = Rc::new(3);
275
+ /// assert!(Rc::would_unwrap(&x));
276
+ /// assert_eq!(Rc::try_unwrap(x), Ok(3));
277
278
+ /// let x = Rc::new(4);
279
+ /// let _y = x.clone();
280
+ /// assert!(!Rc::would_unwrap(&x));
281
+ /// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
282
283
#[unstable(feature = "rc_would_unwrap",
284
reason = "just added for niche usecase",
285
issue = "28356")]
0 commit comments