mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
document behavior of rotations for n >= BITS
This commit is contained in:
@@ -275,6 +275,10 @@ pub const fn cast_unsigned(self) -> $UnsignedT {
|
||||
/// Shifts the bits to the left by a specified amount, `n`,
|
||||
/// wrapping the truncated bits to the end of the resulting integer.
|
||||
///
|
||||
/// `rotate_left(n)` is equivalent to applying `rotate_left(1)` a total of `n` times. In
|
||||
/// particular, a rotation by the number of bits in `self` returns the input value
|
||||
/// unchanged.
|
||||
///
|
||||
/// Please note this isn't the same operation as the `<<` shifting operator!
|
||||
///
|
||||
/// # Examples
|
||||
@@ -284,6 +288,7 @@ pub const fn cast_unsigned(self) -> $UnsignedT {
|
||||
#[doc = concat!("let m = ", $rot_result, ";")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.rotate_left(", $rot, "), m);")]
|
||||
#[doc = concat!("assert_eq!(n.rotate_left(1024), n);")]
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
@@ -298,6 +303,10 @@ pub const fn rotate_left(self, n: u32) -> Self {
|
||||
/// wrapping the truncated bits to the beginning of the resulting
|
||||
/// integer.
|
||||
///
|
||||
/// `rotate_right(n)` is equivalent to applying `rotate_right(1)` a total of `n` times. In
|
||||
/// particular, a rotation by the number of bits in `self` returns the input value
|
||||
/// unchanged.
|
||||
///
|
||||
/// Please note this isn't the same operation as the `>>` shifting operator!
|
||||
///
|
||||
/// # Examples
|
||||
@@ -307,6 +316,7 @@ pub const fn rotate_left(self, n: u32) -> Self {
|
||||
#[doc = concat!("let m = ", $rot_op, ";")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.rotate_right(", $rot, "), m);")]
|
||||
#[doc = concat!("assert_eq!(n.rotate_right(1024), n);")]
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
|
||||
@@ -336,6 +336,10 @@ pub const fn cast_signed(self) -> $SignedT {
|
||||
/// Shifts the bits to the left by a specified amount, `n`,
|
||||
/// wrapping the truncated bits to the end of the resulting integer.
|
||||
///
|
||||
/// `rotate_left(n)` is equivalent to applying `rotate_left(1)` a total of `n` times. In
|
||||
/// particular, a rotation by the number of bits in `self` returns the input value
|
||||
/// unchanged.
|
||||
///
|
||||
/// Please note this isn't the same operation as the `<<` shifting operator!
|
||||
///
|
||||
/// # Examples
|
||||
@@ -345,6 +349,7 @@ pub const fn cast_signed(self) -> $SignedT {
|
||||
#[doc = concat!("let m = ", $rot_result, ";")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.rotate_left(", $rot, "), m);")]
|
||||
#[doc = concat!("assert_eq!(n.rotate_left(1024), n);")]
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
@@ -360,6 +365,10 @@ pub const fn rotate_left(self, n: u32) -> Self {
|
||||
/// wrapping the truncated bits to the beginning of the resulting
|
||||
/// integer.
|
||||
///
|
||||
/// `rotate_right(n)` is equivalent to applying `rotate_right(1)` a total of `n` times. In
|
||||
/// particular, a rotation by the number of bits in `self` returns the input value
|
||||
/// unchanged.
|
||||
///
|
||||
/// Please note this isn't the same operation as the `>>` shifting operator!
|
||||
///
|
||||
/// # Examples
|
||||
@@ -369,6 +378,7 @@ pub const fn rotate_left(self, n: u32) -> Self {
|
||||
#[doc = concat!("let m = ", $rot_op, ";")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.rotate_right(", $rot, "), m);")]
|
||||
#[doc = concat!("assert_eq!(n.rotate_right(1024), n);")]
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
|
||||
Reference in New Issue
Block a user