Skip to content

Commit ab389e5

Browse files
faerntesuji
andcommitted
Use cmp::min instead of manual if-else
Co-Authored-By: lzutao <taolzu@gmail.com>
1 parent c73af28 commit ab389e5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/libstd/sys/unix/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const TIMESPEC_MAX: libc::timespec =
1313
libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
1414

1515
fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
16-
if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
16+
crate::cmp::min(value, libc::time_t::MAX as u64) as _
1717
}
1818

1919
impl Condvar {

src/libstd/sys/vxworks/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const TIMESPEC_MAX: libc::timespec =
1313
libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
1414

1515
fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
16-
if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
16+
crate::cmp::min(value, libc::time_t::MAX as u64) as _
1717
}
1818

1919
impl Condvar {

0 commit comments

Comments
 (0)