1
Fork 0

Add #[must_use] to remaining alloc functions

This commit is contained in:
John Kugelman 2021-10-14 19:56:53 -04:00 committed by Kugelman, John R
parent e1e9319d93
commit fb2d0f5c03
15 changed files with 78 additions and 23 deletions

View file

@ -2246,6 +2246,7 @@ impl<T: ?Sized> Weak<T> {
/// Gets the number of strong (`Rc`) 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() } else { 0 }
@ -2254,6 +2255,7 @@ impl<T: ?Sized> Weak<T> {
/// Gets the number of `Weak` pointers pointing to this allocation.
///
/// If no strong pointers remain, this will return zero.
#[must_use]
#[stable(feature = "weak_counts", since = "1.41.0")]
pub fn weak_count(&self) -> usize {
self.inner()
@ -2324,6 +2326,7 @@ impl<T: ?Sized> Weak<T> {
/// assert!(!first.ptr_eq(&third));
/// ```
#[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()