mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Add #[must_use] to Rc::downgrade
This commit is contained in:
parent
044674337a
commit
5bb99bb02d
@ -41,7 +41,7 @@
|
|||||||
//! use std::rc::Rc;
|
//! use std::rc::Rc;
|
||||||
//!
|
//!
|
||||||
//! let my_rc = Rc::new(());
|
//! 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
|
//! `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);
|
/// 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")]
|
#[stable(feature = "rc_weak", since = "1.4.0")]
|
||||||
pub fn downgrade(this: &Self) -> Weak<T> {
|
pub fn downgrade(this: &Self) -> Weak<T> {
|
||||||
this.inner().inc_weak();
|
this.inner().inc_weak();
|
||||||
|
Loading…
Reference in New Issue
Block a user