Rollup merge of #89833 - jkugelman:must-use-rc-downgrade, r=joshtriplett

Add #[must_use] to Rc::downgrade

Missed this in previous PR https://github.com/rust-lang/rust/pull/89796#issuecomment-941456006

Parent issue: #89692

r? ```@joshtriplett```
This commit is contained in:
Matthias Krüger 2021-10-31 09:20:23 +01:00 committed by GitHub
commit 3cf3910c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -41,7 +41,7 @@
//! use std::rc::Rc;
//!
//! let my_rc = Rc::new(());
//! Rc::downgrade(&my_rc);
//! let my_weak = Rc::downgrade(&my_rc);
//! ```
//!
//! `Rc<T>`'s implementations of traits like `Clone` may also be called using
@ -889,6 +889,8 @@ impl<T: ?Sized> Rc<T> {
///
/// let weak_five = Rc::downgrade(&five);
/// ```
#[must_use = "this returns a new `Weak` pointer, \
without modifying the original `Rc`"]
#[stable(feature = "rc_weak", since = "1.4.0")]
pub fn downgrade(this: &Self) -> Weak<T> {
this.inner().inc_weak();