From 089475a44e9b2644a64816b899a587fa3ef2f728 Mon Sep 17 00:00:00 2001 From: Tethys Svensson Date: Mon, 14 Nov 2022 19:42:47 +0100 Subject: [PATCH 1/2] Fix doc example for `wrapping_abs` The `max` variable is unused. This change introduces the `min_plus` variable, to make the example similar to the one from `saturating_abs`. An alternative would be to remove the unused variable. --- library/core/src/num/nonzero.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 5b7521220acdb..db176de5aa194 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -669,12 +669,15 @@ macro_rules! nonzero_signed_operations { #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")] #[doc = concat!("let min = ", stringify!($Ty), "::new(", stringify!($Int), "::MIN)?;")] + #[doc = concat!("let min_plus = ", stringify!($Ty), "::new(", + stringify!($Int), "::MIN + 1)?;")] #[doc = concat!("let max = ", stringify!($Ty), "::new(", stringify!($Int), "::MAX)?;")] /// /// assert_eq!(pos, pos.wrapping_abs()); /// assert_eq!(pos, neg.wrapping_abs()); /// assert_eq!(min, min.wrapping_abs()); + /// assert_eq!(max, min_plus.wrapping_abs()); /// # // FIXME: add once Neg is implemented? /// # // assert_eq!(max, (-max).wrapping_abs()); /// # Some(()) From 00bf999fcf9b20c3c6ea2bf77eaafaebf8a761de Mon Sep 17 00:00:00 2001 From: Tethys Svensson Date: Sun, 20 Nov 2022 12:30:14 +0100 Subject: [PATCH 2/2] Incorporate review feedback --- library/core/src/num/nonzero.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index db176de5aa194..d2d915371af3e 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -669,15 +669,12 @@ macro_rules! nonzero_signed_operations { #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")] #[doc = concat!("let min = ", stringify!($Ty), "::new(", stringify!($Int), "::MIN)?;")] - #[doc = concat!("let min_plus = ", stringify!($Ty), "::new(", - stringify!($Int), "::MIN + 1)?;")] - #[doc = concat!("let max = ", stringify!($Ty), "::new(", + #[doc = concat!("# let max = ", stringify!($Ty), "::new(", stringify!($Int), "::MAX)?;")] /// /// assert_eq!(pos, pos.wrapping_abs()); /// assert_eq!(pos, neg.wrapping_abs()); /// assert_eq!(min, min.wrapping_abs()); - /// assert_eq!(max, min_plus.wrapping_abs()); /// # // FIXME: add once Neg is implemented? /// # // assert_eq!(max, (-max).wrapping_abs()); /// # Some(())