Skip to content

Commit

Permalink
Stop vendoring saturating_abs
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker authored and djc committed Jun 4, 2023
1 parent 2dbf66f commit 1187e3e
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/offset/local/tz_info/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand All @@ -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"));
Expand Down Expand Up @@ -615,17 +615,6 @@ fn find_tz_file(path: impl AsRef<Path>) -> Result<File, Error> {
}
}

#[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] =
Expand Down

0 comments on commit 1187e3e

Please sign in to comment.