diff options
| author | John Kugelman <john@kugelman.name> | 2021-10-14 19:56:53 -0400 |
|---|---|---|
| committer | Kugelman, John R <Kugelman.John@vast-inc.com> | 2021-10-15 11:46:49 -0400 |
| commit | fb2d0f5c03d2f699eb87bc1986386bdcf6a3f6eb (patch) | |
| tree | 28c56c4502ee837b968171f9508e6f4ca87deed5 /library/alloc/src/sync.rs | |
| parent | e1e9319d93aea755c444c8f8ff863b0936d7a4b6 (diff) | |
| download | rust-fb2d0f5c03d2f699eb87bc1986386bdcf6a3f6eb.tar.gz rust-fb2d0f5c03d2f699eb87bc1986386bdcf6a3f6eb.zip | |
Add #[must_use] to remaining alloc functions
Diffstat (limited to 'library/alloc/src/sync.rs')
| -rw-r--r-- | library/alloc/src/sync.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index b75e9a2f3c7..039971a1765 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -953,6 +953,7 @@ impl<T: ?Sized> Arc<T> { /// assert_eq!(1, Arc::weak_count(&five)); /// ``` #[inline] + #[must_use] #[stable(feature = "arc_counts", since = "1.15.0")] pub fn weak_count(this: &Self) -> usize { let cnt = this.inner().weak.load(SeqCst); @@ -982,6 +983,7 @@ impl<T: ?Sized> Arc<T> { /// assert_eq!(2, Arc::strong_count(&five)); /// ``` #[inline] + #[must_use] #[stable(feature = "arc_counts", since = "1.15.0")] pub fn strong_count(this: &Self) -> usize { this.inner().strong.load(SeqCst) @@ -1079,8 +1081,6 @@ impl<T: ?Sized> Arc<T> { drop(Weak { ptr: self.ptr }); } - #[inline] - #[stable(feature = "ptr_eq", since = "1.17.0")] /// Returns `true` if the two `Arc`s point to the same allocation /// (in a vein similar to [`ptr::eq`]). /// @@ -1098,6 +1098,9 @@ impl<T: ?Sized> Arc<T> { /// ``` /// /// [`ptr::eq`]: core::ptr::eq "ptr::eq" + #[inline] + #[must_use] + #[stable(feature = "ptr_eq", since = "1.17.0")] pub fn ptr_eq(this: &Self, other: &Self) -> bool { this.ptr.as_ptr() == other.ptr.as_ptr() } @@ -1904,6 +1907,7 @@ impl<T: ?Sized> Weak<T> { /// Gets the number of strong (`Arc`) pointers pointing to this allocation. /// /// If `self` was created using [`Weak::new`], this will return 0. + #[must_use] #[stable(feature = "weak_counts", since = "1.41.0")] pub fn strong_count(&self) -> usize { if let Some(inner) = self.inner() { inner.strong.load(SeqCst) } else { 0 } @@ -1920,6 +1924,7 @@ impl<T: ?Sized> Weak<T> { /// Due to implementation details, the returned value can be off by 1 in /// either direction when other threads are manipulating any `Arc`s or /// `Weak`s pointing to the same allocation. + #[must_use] #[stable(feature = "weak_counts", since = "1.41.0")] pub fn weak_count(&self) -> usize { self.inner() @@ -1999,6 +2004,7 @@ impl<T: ?Sized> Weak<T> { /// /// [`ptr::eq`]: core::ptr::eq "ptr::eq" #[inline] + #[must_use] #[stable(feature = "weak_ptr_eq", since = "1.39.0")] pub fn ptr_eq(&self, other: &Self) -> bool { self.ptr.as_ptr() == other.ptr.as_ptr() |
