about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Kugelman <john@kugelman.name>2021-10-12 18:27:03 -0400
committerJohn Kugelman <john@kugelman.name>2021-10-12 18:53:56 -0400
commit5bb99bb02d6d0ec4d9239fd9bce48a41fb084811 (patch)
treeee5b8e083c4b21509efff90a239dc838b2f78065
parent044674337a180c494b7e6fdce4b20dca93324b2a (diff)
downloadrust-5bb99bb02d6d0ec4d9239fd9bce48a41fb084811.tar.gz
rust-5bb99bb02d6d0ec4d9239fd9bce48a41fb084811.zip
Add #[must_use] to Rc::downgrade
-rw-r--r--library/alloc/src/rc.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index 493cf3117ed..e9cded67364 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -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();