```
"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() }
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() }
+ }
+
doc_comment! {
concat!("Returns the number of zeros in the binary representation of `self`.
", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 1);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn count_zeros(self) -> u32 {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentatio"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn count_zeros(self) -> u32 {
+ (!self).count_ones()
+ }
+ }
+
doc_comment! {
concat!("Returns the number of leading zeros in the binary representation of `self`.
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn leading_zeros(self) -> u32 {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn leading_zeros(self) -> u32 {
+ (self as $UnsignedT).leading_zeros()
+ }
+ }
+
doc_comment! {
concat!("Returns the number of trailing zeros in the binary representation of `self`.
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn trailing_zeros(self) -> u32 {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn trailing_zeros(self) -> u32 {
+ (self as $UnsignedT).trailing_zeros()
+ }
+ }
+
/// Shifts the bits to the left by a specified amount, `n`,
/// wrapping the truncated bits to the end of the resulting integer.
///
/// assert_eq!(m, 21760);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn swap_bytes(self) -> Self {
(self as $UnsignedT).swap_bytes() as Self
}
+ /// Dummy docs. See !stage0 documentation.
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn swap_bytes(self) -> Self {
+ (self as $UnsignedT).swap_bytes() as Self
+ }
+
/// Reverses the bit pattern of the integer.
///
/// # Examples
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn from_be(x: Self) -> Self {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn from_be(x: Self) -> Self {
+ if cfg!(target_endian = "big") { x } else { x.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Converts an integer from little endian to the target's endianness.
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn from_le(x: Self) -> Self {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn from_le(x: Self) -> Self {
+ if cfg!(target_endian = "little") { x } else { x.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Converts `self` to big endian from the target's endianness.
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn to_be(self) -> Self { // or not to be?
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn to_be(self) -> Self { // or not to be?
+ if cfg!(target_endian = "big") { self } else { self.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Converts `self` to little endian from the target's endianness.
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn to_le(self) -> Self {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn to_le(self) -> Self {
+ if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Checked integer addition. Computes `self + rhs`, returning `None`
if overflow occurred.
assert_eq!(n.count_ones(), 3);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn count_ones(self) -> u32 {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn count_ones(self) -> u32 {
+ unsafe { intrinsics::ctpop(self as $ActualT) as u32 }
+ }
+ }
+
doc_comment! {
concat!("Returns the number of zeros in the binary representation of `self`.
", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 0);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn count_zeros(self) -> u32 {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn count_zeros(self) -> u32 {
+ (!self).count_ones()
+ }
+ }
+
doc_comment! {
concat!("Returns the number of leading zeros in the binary representation of `self`.
assert_eq!(n.leading_zeros(), 2);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn leading_zeros(self) -> u32 {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn leading_zeros(self) -> u32 {
+ unsafe { intrinsics::ctlz(self as $ActualT) as u32 }
+ }
+ }
+
doc_comment! {
concat!("Returns the number of trailing zeros in the binary representation
of `self`.
assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn trailing_zeros(self) -> u32 {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn trailing_zeros(self) -> u32 {
+ unsafe { uint_cttz_call!(self, $BITS) as u32 }
+ }
+ }
+
/// Shifts the bits to the left by a specified amount, `n`,
/// wrapping the truncated bits to the end of the resulting integer.
///
/// assert_eq!(m, 21760);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn swap_bytes(self) -> Self {
unsafe { intrinsics::bswap(self as $ActualT) as Self }
}
+ /// Dummy docs. See !stage0 documentation.
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn swap_bytes(self) -> Self {
+ unsafe { intrinsics::bswap(self as $ActualT) as Self }
+ }
+
/// Reverses the bit pattern of the integer.
///
/// # Examples
}", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn from_be(x: Self) -> Self {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn from_be(x: Self) -> Self {
+ if cfg!(target_endian = "big") { x } else { x.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Converts an integer from little endian to the target's endianness.
}", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn from_le(x: Self) -> Self {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn from_le(x: Self) -> Self {
+ if cfg!(target_endian = "little") { x } else { x.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Converts `self` to big endian from the target's endianness.
}", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn to_be(self) -> Self { // or not to be?
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn to_be(self) -> Self { // or not to be?
+ if cfg!(target_endian = "big") { self } else { self.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Converts `self` to little endian from the target's endianness.
}", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(not(stage0))]
#[rustc_const_unstable(feature = "const_int_ops")]
#[inline]
pub const fn to_le(self) -> Self {
}
}
+ doc_comment! {
+ concat!("Dummy docs. See !stage0 documentation"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
+ #[inline]
+ pub fn to_le(self) -> Self {
+ if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
+ }
+ }
+
doc_comment! {
concat!("Checked integer addition. Computes `self + rhs`, returning `None`
if overflow occurred.