Rollup merge of #61134 - nvzqz:reverse_bits-must_use, r=varkor

Annotate each `reverse_bits` with `#[must_use]`

Because the name sounds like an in-place mutation like `[T]::reverse(&mut self)`, it may be confused for one.

This change was requested at https://github.com/rust-lang/rust/issues/48763#issuecomment-493743741.
This commit is contained in:
Mazdak Farrokhzad 2019-05-25 04:55:43 +02:00 committed by GitHub
commit 92f1cfd039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -473,6 +473,7 @@ assert_eq!(m, ", $reversed, ");
#[unstable(feature = "reverse_bits", issue = "48763")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self {
(self as $UnsignedT).reverse_bits() as Self
}
@ -2522,6 +2523,7 @@ assert_eq!(m, ", $reversed, ");
```"),
#[unstable(feature = "reverse_bits", issue = "48763")]
#[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self {
intrinsics::bitreverse(self as $ActualT) as Self
}

View File

@ -524,6 +524,7 @@ assert_eq!(n.trailing_zeros(), 3);
/// ```
#[unstable(feature = "reverse_bits", issue = "48763")]
#[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self {
Wrapping(self.0.reverse_bits())
}