From 0156ef12fa7e8f7db48a6f4f2ee8b9568425d5ab Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 18 Sep 2021 14:21:57 -0400 Subject: [PATCH 01/14] Max working. --- library/core/src/num/nonzero.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index dd9b9330aee2b..2ef5754416f48 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -895,3 +895,23 @@ macro_rules! nonzero_unsigned_is_power_of_two { } nonzero_unsigned_is_power_of_two! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize } + +macro_rules! nonzero_max { + ( $( $Ty: ident($Int: ty) )+ ) => { + $( + + impl $Ty { + #[unstable(feature = "nonzero_max", issue = "89065")] + #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), ">::MAX);")] + //SAFETY: Since the MAX value, for any supported integer type, is greater than 0, + // the MAX will always be non-zero. + pub const MAX : $Ty = unsafe { $Ty::new_unchecked(<$Int>::MAX) }; + } + )+ + } +} + +nonzero_max! { NonZeroU8(u8) NonZeroI8(i8) NonZeroU16(u16) NonZeroI16(i16) NonZeroU32(u32) NonZeroI32(i32) + NonZeroU64(u64) NonZeroI64(i64) NonZeroUsize(usize) NonZeroIsize(isize) +} From b5c1fe19ccfe2af2cedcd0f8fea75bf2bb92de15 Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 18 Sep 2021 15:03:31 -0400 Subject: [PATCH 02/14] nonzero min and nonzero max working. --- library/core/src/num/nonzero.rs | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 2ef5754416f48..969eaac1e8b48 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -896,22 +896,41 @@ macro_rules! nonzero_unsigned_is_power_of_two { nonzero_unsigned_is_power_of_two! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize } -macro_rules! nonzero_max { - ( $( $Ty: ident($Int: ty) )+ ) => { +macro_rules! nonzero_min_max { + ( $( $min:expr , $Ty: ident($Int: ty); )+ ) => { $( impl $Ty { #[unstable(feature = "nonzero_max", issue = "89065")] #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] - #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), ">::MAX);")] + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] //SAFETY: Since the MAX value, for any supported integer type, is greater than 0, // the MAX will always be non-zero. pub const MAX : $Ty = unsafe { $Ty::new_unchecked(<$Int>::MAX) }; - } + #[unstable(feature = "nonzero_min", issue = "89065")] + #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] + /// # Examples + /// + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($min), ";")] + //SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero. + // In the unsignedd case, we use one, which is non-zero. + pub const MIN : $Ty = unsafe { $Ty::new_unchecked($min)}; + } )+ } } -nonzero_max! { NonZeroU8(u8) NonZeroI8(i8) NonZeroU16(u16) NonZeroI16(i16) NonZeroU32(u32) NonZeroI32(i32) - NonZeroU64(u64) NonZeroI64(i64) NonZeroUsize(usize) NonZeroIsize(isize) +nonzero_min_max! { + 1 , NonZeroU8(u8); + 1 , NonZeroU16(u16); + 1 , NonZeroU32(u32); + 1 , NonZeroU64(u64); + 1 , NonZeroU128(u128); + 1 , NonZeroUsize(usize); + i8::MIN , NonZeroI8(i8); + i16::MIN , NonZeroI16(i16); + i32::MIN , NonZeroI32(i32); + i64::MIN , NonZeroI64(i64); + i128::MIN , NonZeroI128(i128); + isize::MIN , NonZeroIsize(isize); } From 84d88f2ae9085800d958d1c46a522cebfa72f63f Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 18 Sep 2021 16:11:09 -0400 Subject: [PATCH 03/14] Fixed some formatting issues. --- library/core/src/num/nonzero.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 969eaac1e8b48..a27ec0e11674b 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -899,23 +899,20 @@ nonzero_unsigned_is_power_of_two! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 N macro_rules! nonzero_min_max { ( $( $min:expr , $Ty: ident($Int: ty); )+ ) => { $( - impl $Ty { - #[unstable(feature = "nonzero_max", issue = "89065")] + #[unstable(feature = "nonzero_max", issue = "89065")] #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] - //SAFETY: Since the MAX value, for any supported integer type, is greater than 0, - // the MAX will always be non-zero. + // SAFETY: Since the MAX value, for any supported integer type, is greater than 0, the MAX will always be non-zero. pub const MAX : $Ty = unsafe { $Ty::new_unchecked(<$Int>::MAX) }; #[unstable(feature = "nonzero_min", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] - /// # Examples - /// + /// # Examples #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($min), ";")] - //SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero. - // In the unsignedd case, we use one, which is non-zero. + // SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero. + // SAFETY: In the unsignedd case, we use one, which is non-zero. pub const MIN : $Ty = unsafe { $Ty::new_unchecked($min)}; - } + } )+ } } From b2740229f302618b08b4830123b49529970a3724 Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 18 Sep 2021 16:11:56 -0400 Subject: [PATCH 04/14] Made a macro name consistent. --- library/core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index a27ec0e11674b..ea882a098e12e 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -897,7 +897,7 @@ macro_rules! nonzero_unsigned_is_power_of_two { nonzero_unsigned_is_power_of_two! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize } macro_rules! nonzero_min_max { - ( $( $min:expr , $Ty: ident($Int: ty); )+ ) => { + ( $( $MinVal:expr , $Ty: ident($Int: ty); )+ ) => { $( impl $Ty { #[unstable(feature = "nonzero_max", issue = "89065")] From 0f84d19b65d973f2514027615d23b30a253da6b6 Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 18 Sep 2021 16:23:33 -0400 Subject: [PATCH 05/14] Fixed variable name _properly_ --- library/core/src/num/nonzero.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index ea882a098e12e..436e3eb708ad4 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -908,10 +908,10 @@ macro_rules! nonzero_min_max { #[unstable(feature = "nonzero_min", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] /// # Examples - #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($min), ";")] + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Min), ";")] // SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero. // SAFETY: In the unsignedd case, we use one, which is non-zero. - pub const MIN : $Ty = unsafe { $Ty::new_unchecked($min)}; + pub const MIN : $Ty = unsafe { $Ty::new_unchecked($Min)}; } )+ } From 279f0bfab21863231e18ed2f50439bfc0e0bb8e6 Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 18 Sep 2021 16:31:41 -0400 Subject: [PATCH 06/14] Fixed build errors. --- library/core/src/num/nonzero.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 436e3eb708ad4..6796af2fbfc5e 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -908,10 +908,10 @@ macro_rules! nonzero_min_max { #[unstable(feature = "nonzero_min", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] /// # Examples - #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Min), ";")] + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($MinVal), ";")] // SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero. // SAFETY: In the unsignedd case, we use one, which is non-zero. - pub const MIN : $Ty = unsafe { $Ty::new_unchecked($Min)}; + pub const MIN : $Ty = unsafe { $Ty::new_unchecked($MinVal)}; } )+ } From 591b89dbd58d890f2e13fadbcfc78f590ec5da4b Mon Sep 17 00:00:00 2001 From: mjclements Date: Mon, 20 Sep 2021 19:42:14 -0400 Subject: [PATCH 07/14] Addressing PR Comment. --- library/core/src/num/nonzero.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 6796af2fbfc5e..e212fcae92251 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -900,12 +900,12 @@ macro_rules! nonzero_min_max { ( $( $MinVal:expr , $Ty: ident($Int: ty); )+ ) => { $( impl $Ty { - #[unstable(feature = "nonzero_max", issue = "89065")] + #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] // SAFETY: Since the MAX value, for any supported integer type, is greater than 0, the MAX will always be non-zero. pub const MAX : $Ty = unsafe { $Ty::new_unchecked(<$Int>::MAX) }; - #[unstable(feature = "nonzero_min", issue = "89065")] + #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] /// # Examples #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($MinVal), ";")] From 56ce3a293e790f0085234da3ec1feb0de78e0180 Mon Sep 17 00:00:00 2001 From: mjclements Date: Mon, 20 Sep 2021 19:58:59 -0400 Subject: [PATCH 08/14] Removed {unsafe} since we are in constant context. --- library/core/src/num/nonzero.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index e212fcae92251..03b6a3188a4e3 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -903,15 +903,12 @@ macro_rules! nonzero_min_max { #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] - // SAFETY: Since the MAX value, for any supported integer type, is greater than 0, the MAX will always be non-zero. - pub const MAX : $Ty = unsafe { $Ty::new_unchecked(<$Int>::MAX) }; + pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ; #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] /// # Examples #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($MinVal), ";")] - // SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero. - // SAFETY: In the unsignedd case, we use one, which is non-zero. - pub const MIN : $Ty = unsafe { $Ty::new_unchecked($MinVal)}; + pub const MIN : $Ty = $Ty::new($MinVal).unwrap(); } )+ } From 3cbfdecc92d3a1422291e72cea24e8f07412055c Mon Sep 17 00:00:00 2001 From: mjclements Date: Wed, 22 Sep 2021 18:04:07 -0400 Subject: [PATCH 09/14] Split macro, added documentation. --- library/core/src/num/nonzero.rs | 62 ++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 03b6a3188a4e3..e34b114e3e84d 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -896,35 +896,63 @@ macro_rules! nonzero_unsigned_is_power_of_two { nonzero_unsigned_is_power_of_two! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize } -macro_rules! nonzero_min_max { - ( $( $MinVal:expr , $Ty: ident($Int: ty); )+ ) => { +macro_rules! nonzero_constants_signed { + ( $( $Ty: ident($Int: ty); )+ ) => { $( impl $Ty { #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] + /// # Examples #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ; #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] /// # Examples - #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($MinVal), ";")] - pub const MIN : $Ty = $Ty::new($MinVal).unwrap(); + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN;")] + pub const MIN : $Ty = $Ty::new(<$Int>::MIN).unwrap(); } )+ } } -nonzero_min_max! { - 1 , NonZeroU8(u8); - 1 , NonZeroU16(u16); - 1 , NonZeroU32(u32); - 1 , NonZeroU64(u64); - 1 , NonZeroU128(u128); - 1 , NonZeroUsize(usize); - i8::MIN , NonZeroI8(i8); - i16::MIN , NonZeroI16(i16); - i32::MIN , NonZeroI32(i32); - i64::MIN , NonZeroI64(i64); - i128::MIN , NonZeroI128(i128); - isize::MIN , NonZeroIsize(isize); +nonzero_constants_signed! { + NonZeroI8(i8); + NonZeroI16(i16); + NonZeroI32(i32); + NonZeroI64(i64); + NonZeroI128(i128); + NonZeroIsize(isize); +} + +macro_rules! nonzero_constants_unsigned{ + ( $( $Ty: ident($Int: ty); )+ ) => { + $( + impl $Ty { + #[unstable(feature = "nonzero_min_max", issue = "89065")] + #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] + /// Note, while most integer types are defined for every whole number between MIN and + /// MAX, signed non-zero integers are a special case. They have a 'gap' at 0. + /// # Examples + pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ; + #[unstable(feature = "nonzero_min_max", issue = "89065")] + #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] + /// Note, while most integer types are defined for every whole number between MIN and + /// MAX, signed non-zero integers are a special case. They have a 'gap' at 0. + /// # Examples + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN;")] + pub const MIN : $Ty = $Ty::new(1).unwrap(); + } + )+ + } +} + + +nonzero_constants_unsigned! { + NonZeroU8(u8); + NonZeroU16(u16); + NonZeroU32(u32); + NonZeroU64(u64); + NonZeroU128(u128); + NonZeroUsize(usize); } From 7a718e1b5b9f515c6baedd98cbc420edbf1e69a4 Mon Sep 17 00:00:00 2001 From: mjclements Date: Wed, 22 Sep 2021 21:41:58 -0400 Subject: [PATCH 10/14] Trailing ws. --- library/core/src/num/nonzero.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index e34b114e3e84d..5cf3e454e262c 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -947,7 +947,6 @@ macro_rules! nonzero_constants_unsigned{ } } - nonzero_constants_unsigned! { NonZeroU8(u8); NonZeroU16(u16); From 87d92f96cf3e926351a6b93dfd74b961e812a25c Mon Sep 17 00:00:00 2001 From: mjclements Date: Thu, 23 Sep 2021 09:15:20 -0400 Subject: [PATCH 11/14] Tidy cleanup comment, trailing WS --- library/core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 5cf3e454e262c..3c727f890b6ff 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -933,7 +933,7 @@ macro_rules! nonzero_constants_unsigned{ #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] /// Note, while most integer types are defined for every whole number between MIN and /// MAX, signed non-zero integers are a special case. They have a 'gap' at 0. - /// # Examples + /// # Examples pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ; #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] From 2fecb01b1ba0709ef0764716eceffb3d49a450b3 Mon Sep 17 00:00:00 2001 From: Clements <37786996+mjclements@users.noreply.github.com> Date: Fri, 24 Sep 2021 12:20:02 -0400 Subject: [PATCH 12/14] Update library/core/src/num/nonzero.rs Co-authored-by: LingMan --- library/core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 3c727f890b6ff..16f1265e41f88 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -904,7 +904,7 @@ macro_rules! nonzero_constants_signed { #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] /// # Examples #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] - pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ; + pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap(); #[unstable(feature = "nonzero_min_max", issue = "89065")] #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] /// # Examples From 5b48c54186b8adb3ac950df9c163fc6e765b6687 Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 25 Sep 2021 12:07:12 -0400 Subject: [PATCH 13/14] Cleaned up some documentation. --- library/core/src/num/nonzero.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 16f1265e41f88..f238548f79f21 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -901,16 +901,22 @@ macro_rules! nonzero_constants_signed { $( impl $Ty { #[unstable(feature = "nonzero_min_max", issue = "89065")] - #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] + #[doc = concat!("The maximum value for a `", stringify!($Ty), "` is the same as `", stringify!($Int), "`.")] /// # Examples + /// + /// ``` #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] + /// ``` pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap(); #[unstable(feature = "nonzero_min_max", issue = "89065")] - #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] + #[doc = concat!("The minimum value for a `", stringify!($Ty), " `.")] /// # Examples + /// + /// ``` #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN;")] + /// ``` pub const MIN : $Ty = $Ty::new(<$Int>::MIN).unwrap(); - } + } )+ } } @@ -929,20 +935,26 @@ macro_rules! nonzero_constants_unsigned{ $( impl $Ty { #[unstable(feature = "nonzero_min_max", issue = "89065")] - #[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")] - #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] - /// Note, while most integer types are defined for every whole number between MIN and + #[doc = concat!("The maximum value for a `", stringify!($Ty), "` is the same as `", stringify!($Int), "`.")] + /// Note: While most integer types are defined for every whole number between MIN and /// MAX, signed non-zero integers are a special case. They have a 'gap' at 0. /// # Examples + /// + /// ``` + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")] + /// ``` pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ; #[unstable(feature = "nonzero_min_max", issue = "89065")] - #[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")] - /// Note, while most integer types are defined for every whole number between MIN and + #[doc = concat!("The minimum value for a `", stringify!($Ty), "`.")] + /// Note: While most integer types are defined for every whole number between MIN and /// MAX, signed non-zero integers are a special case. They have a 'gap' at 0. /// # Examples + /// + /// ``` #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN;")] + /// ``` pub const MIN : $Ty = $Ty::new(1).unwrap(); - } + } )+ } } From 5ac53efc204a0b286d2e8503c761bb06d4c5e563 Mon Sep 17 00:00:00 2001 From: mjclements Date: Sat, 25 Sep 2021 12:40:36 -0400 Subject: [PATCH 14/14] Fixes missing parenthesis in doc test. --- library/core/src/num/nonzero.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index f238548f79f21..d643f2bea9d95 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -913,7 +913,7 @@ macro_rules! nonzero_constants_signed { /// # Examples /// /// ``` - #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN;")] + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN);")] /// ``` pub const MIN : $Ty = $Ty::new(<$Int>::MIN).unwrap(); } @@ -951,7 +951,7 @@ macro_rules! nonzero_constants_unsigned{ /// # Examples /// /// ``` - #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN;")] + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($Int), "::MIN);")] /// ``` pub const MIN : $Ty = $Ty::new(1).unwrap(); }