mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-09 00:17:44 +00:00
![]() Simplify checked_duration_since This follows the same design as we updated to in #56490. Internally, all the system specific time implementations are checked, no panics. Then the panicking publicly exported API can just call the checked version of itself and make do with a single panic (`expect`) at the top. Since the internal sys implementations are now checked, this gets rid of the extra `if self >= &earlier` check in `checked_duration_since`. Except likely making the generated machine code simpler, it also reduces the algorithm from "Check panic condition -> call possibly panicking method" to just "call non panicking method". Added two test cases: * Edge case: Make sure `checked_duration_since` on two equal `Instant`s produce a zero duration, not a `None`. * Most common/intended usage: Make sure `later.checked_duration_since(earlier)`, returns an expected value. |
||
---|---|---|
.. | ||
backtrace | ||
ext | ||
process | ||
alloc.rs | ||
android.rs | ||
args.rs | ||
cmath.rs | ||
condvar.rs | ||
env.rs | ||
fast_thread_local.rs | ||
fd.rs | ||
fs.rs | ||
io.rs | ||
l4re.rs | ||
memchr.rs | ||
mod.rs | ||
mutex.rs | ||
net.rs | ||
os.rs | ||
path.rs | ||
pipe.rs | ||
rand.rs | ||
rwlock.rs | ||
stack_overflow.rs | ||
stdio.rs | ||
thread_local.rs | ||
thread.rs | ||
time.rs | ||
weak.rs |