From a56b4f53921e88669aa7ba5518739556d309cdf9 Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Sun, 4 Jun 2023 10:23:35 +0200 Subject: [PATCH] Stop vendoring `saturating_abs` --- src/offset/local/tz_info/timezone.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/offset/local/tz_info/timezone.rs b/src/offset/local/tz_info/timezone.rs index 33c89060ce..d2de060237 100644 --- a/src/offset/local/tz_info/timezone.rs +++ b/src/offset/local/tz_info/timezone.rs @@ -321,7 +321,7 @@ impl<'a> TimeZoneRef<'a> { // Check leap seconds if !(self.leap_seconds.is_empty() || self.leap_seconds[0].unix_leap_time >= 0 - && saturating_abs(self.leap_seconds[0].correction) == 1) + && self.leap_seconds[0].correction.saturating_abs() == 1) { return Err(Error::TimeZone("invalid leap second")); } @@ -336,7 +336,7 @@ impl<'a> TimeZoneRef<'a> { let diff_unix_leap_time = x1.unix_leap_time.saturating_sub(x0.unix_leap_time); let abs_diff_correction = - saturating_abs(x1.correction.saturating_sub(x0.correction)); + x1.correction.saturating_sub(x0.correction).saturating_abs(); if !(diff_unix_leap_time >= min_interval && abs_diff_correction == 1) { return Err(Error::TimeZone("invalid leap second")); @@ -615,17 +615,6 @@ fn find_tz_file(path: impl AsRef) -> Result { } } -#[inline] -const fn saturating_abs(v: i32) -> i32 { - if v.is_positive() { - v - } else if v == i32::min_value() { - i32::max_value() - } else { - -v - } -} - // Possible system timezone directories #[cfg(unix)] const ZONE_INFO_DIRECTORIES: [&str; 4] =