diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs
index 1f435784be14c..147f04a3f125d 100644
--- a/library/core/src/num/int_macros.rs
+++ b/library/core/src/num/int_macros.rs
@@ -2,9 +2,10 @@ macro_rules! int_impl {
($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $BITS_MINUS_ONE:expr, $Min:expr, $Max:expr,
$rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
$reversed:expr, $le_bytes:expr, $be_bytes:expr,
- $to_xe_bytes_doc:expr, $from_xe_bytes_doc:expr) => {
- /// The smallest value that can be represented by this integer type,
- #[doc = concat!("−2", $BITS_MINUS_ONE, ".")]
+ $to_xe_bytes_doc:expr, $from_xe_bytes_doc:expr,
+ $bound_condition:expr) => {
+ /// The smallest value that can be represented by this integer type
+ #[doc = concat!("(−2", $BITS_MINUS_ONE, "", $bound_condition, ")")]
///
/// # Examples
///
@@ -16,8 +17,8 @@ macro_rules! int_impl {
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
- /// The largest value that can be represented by this integer type,
- #[doc = concat!("2", $BITS_MINUS_ONE, " − 1.")]
+ /// The largest value that can be represented by this integer type
+ #[doc = concat!("(2", $BITS_MINUS_ONE, " − 1", $bound_condition, ")")]
///
/// # Examples
///
diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs
index 66193eaf5da73..f481399fdcf92 100644
--- a/library/core/src/num/mod.rs
+++ b/library/core/src/num/mod.rs
@@ -196,25 +196,25 @@ macro_rules! widening_impl {
impl i8 {
int_impl! { i8, i8, u8, 8, 7, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
- "[0x12]", "[0x12]", "", "" }
+ "[0x12]", "[0x12]", "", "", "" }
}
impl i16 {
int_impl! { i16, i16, u16, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
- "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
+ "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "", "" }
}
impl i32 {
int_impl! { i32, i32, u32, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
- "[0x12, 0x34, 0x56, 0x78]", "", "" }
+ "[0x12, 0x34, 0x56, 0x78]", "", "", "" }
}
impl i64 {
int_impl! { i64, i64, u64, 64, 63, -9223372036854775808, 9223372036854775807, 12,
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "", "" }
+ "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "", "", "" }
}
impl i128 {
@@ -225,14 +225,15 @@ impl i128 {
"[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \
0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \
- 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]", "", "" }
+ 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]", "", "", "" }
}
#[cfg(target_pointer_width = "16")]
impl isize {
int_impl! { isize, i16, usize, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]",
- usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
+ usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!(),
+ " on 16-bit targets" }
}
#[cfg(target_pointer_width = "32")]
@@ -240,7 +241,8 @@ impl isize {
int_impl! { isize, i32, usize, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78]",
- usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
+ usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!(),
+ " on 32-bit targets" }
}
#[cfg(target_pointer_width = "64")]
@@ -249,7 +251,8 @@ impl isize {
12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",
- usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
+ usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!(),
+ " on 64-bit targets" }
}
/// If 6th bit set ascii is upper case.
@@ -257,7 +260,7 @@ const ASCII_CASE_MASK: u8 = 0b0010_0000;
impl u8 {
uint_impl! { u8, u8, i8, NonZeroU8, 8, 255, 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]",
- "[0x12]", "", "" }
+ "[0x12]", "", "", "" }
widening_impl! { u8, u16, 8, unsigned }
/// Checks if the value is within the ASCII range.
@@ -810,7 +813,7 @@ impl u8 {
impl u16 {
uint_impl! { u16, u16, i16, NonZeroU16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
- "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
+ "[0x34, 0x12]", "[0x12, 0x34]", "", "", "" }
widening_impl! { u16, u32, 16, unsigned }
/// Checks if the value is a Unicode surrogate code point, which are disallowed values for [`char`].
@@ -841,7 +844,7 @@ impl u16 {
impl u32 {
uint_impl! { u32, u32, i32, NonZeroU32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
- "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
+ "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "", "" }
widening_impl! { u32, u64, 32, unsigned }
}
@@ -850,7 +853,7 @@ impl u64 {
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",
- "", ""}
+ "", "", ""}
widening_impl! { u64, u128, 64, unsigned }
}
@@ -862,21 +865,23 @@ impl u128 {
0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \
0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]",
- "", ""}
+ "", "", ""}
}
#[cfg(target_pointer_width = "16")]
impl usize {
uint_impl! { usize, u16, isize, NonZeroUsize, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
"[0x34, 0x12]", "[0x12, 0x34]",
- usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
+ usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!(),
+ " on 16-bit targets" }
widening_impl! { usize, u32, 16, unsigned }
}
#[cfg(target_pointer_width = "32")]
impl usize {
uint_impl! { usize, u32, isize, NonZeroUsize, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]",
- usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
+ usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!(),
+ " on 32-bit targets" }
widening_impl! { usize, u64, 32, unsigned }
}
@@ -886,7 +891,8 @@ impl usize {
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",
- usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
+ usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!(),
+ " on 64-bit targets" }
widening_impl! { usize, u128, 64, unsigned }
}
diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs
index cd4b0e18c4dff..715e78350a499 100644
--- a/library/core/src/num/uint_macros.rs
+++ b/library/core/src/num/uint_macros.rs
@@ -3,7 +3,8 @@ macro_rules! uint_impl {
$BITS:expr, $MaxV:expr,
$rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
$reversed:expr, $le_bytes:expr, $be_bytes:expr,
- $to_xe_bytes_doc:expr, $from_xe_bytes_doc:expr) => {
+ $to_xe_bytes_doc:expr, $from_xe_bytes_doc:expr,
+ $bound_condition:expr) => {
/// The smallest value that can be represented by this integer type.
///
/// # Examples
@@ -16,8 +17,8 @@ macro_rules! uint_impl {
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN: Self = 0;
- /// The largest value that can be represented by this integer type,
- #[doc = concat!("2", $BITS, " − 1.")]
+ /// The largest value that can be represented by this integer type
+ #[doc = concat!("(2", $BITS, " − 1", $bound_condition, ")")]
///
/// # Examples
///