From 340c94ad76888d3cbc80f34651c08c29aa084e0d Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 4 Nov 2020 11:12:33 +0000 Subject: [PATCH] Expand explanation of reverse_bits --- library/core/src/num/int_macros.rs | 4 +++- library/core/src/num/uint_macros.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 295a876773c48..728381b658f7c 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -274,7 +274,8 @@ assert_eq!(m, ", $swapped, "); } doc_comment! { - concat!("Reverses the bit pattern of the integer. + concat!("Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, + second least-significant bit becomes second most-significant bit, etc. # Examples @@ -285,6 +286,7 @@ let n = ", $swap_op, stringify!($SelfT), "; let m = n.reverse_bits(); assert_eq!(m, ", $reversed, "); +assert_eq!(0, 0", stringify!($SelfT), ".reverse_bits()); ```"), #[stable(feature = "reverse_bits", since = "1.37.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index bdea0ea3b08c0..adcbbf91433b6 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -272,7 +272,8 @@ assert_eq!(m, ", $swapped, "); } doc_comment! { - concat!("Reverses the bit pattern of the integer. + concat!("Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, + second least-significant bit becomes second most-significant bit, etc. # Examples @@ -283,6 +284,7 @@ let n = ", $swap_op, stringify!($SelfT), "; let m = n.reverse_bits(); assert_eq!(m, ", $reversed, "); +assert_eq!(0, 0", stringify!($SelfT), ".reverse_bits()); ```"), #[stable(feature = "reverse_bits", since = "1.37.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")]