From 59ac1cdfebf93dcf3fdff8ba7d004b66ecdcf438 Mon Sep 17 00:00:00 2001 From: Casper Meijn Date: Thu, 19 Dec 2024 13:50:56 +0100 Subject: [PATCH] style: Use numeric constant This solves clippy warnings like this: ``` error: usage of a legacy numeric method --> src/common.rs:418:31 | 418 | Number::from(i32::min_value()).as_i64(), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `-D clippy::legacy-numeric-constants` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::legacy_numeric_constants)]` help: use the associated constant instead | 418 | Number::from(i32::MIN).as_i64(), | ~~~ ``` --- src/common.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/common.rs b/src/common.rs index 3261df9..7225bc6 100644 --- a/src/common.rs +++ b/src/common.rs @@ -414,14 +414,8 @@ mod tests { fn number_from_i32_and_to_i64_conversion() { assert_eq!(Number::from(1).as_i64(), Some(1)); assert_eq!(Number::from(584).as_i64(), Some(584)); - assert_eq!( - Number::from(i32::min_value()).as_i64(), - Some(i32::min_value() as i64) - ); - assert_eq!( - Number::from(i32::max_value()).as_i64(), - Some(i32::max_value() as i64) - ); + assert_eq!(Number::from(i32::MIN).as_i64(), Some(i32::MIN as i64)); + assert_eq!(Number::from(i32::MAX).as_i64(), Some(i32::MAX as i64)); } #[test]