Document arithmetic operations on Instant
Some questions that have come up about using Instants:
- What meaning does
Instant -= Durationhave? - What are the preconditions on the instant and the duration, so that it does not panic or cause arithmetic overflow assertions? One user noticed that
instant -= durationcan trip this assertion (specifically on Windows).
The zero point of
Instantis not specified and could be any time before the start of the process. If you want to ensure that you do not get any underflow errors, then do not attempt to create anInstantrepresenting a time before the process was spawned.Peter Atashian at 2017-10-24 03:02:56
@rust-lang/libs: if you can articulate which aspects of this API are guaranteed, I'm happy to document them.
Steve Klabnik at 2019-01-10 16:28:37
- What meaning does
Instant -= Durationhave?
It causes
Instantto have the value of anInstantcreatedDurationtime before its original value.- What are the preconditions on the instant and the duration, so that it does not panic or cause arithmetic overflow assertions?
Instantcurrently wraps the platform-specific monotonic time type, so the overflow bounds depend on the system. Some probably safe assumptions would be to not createInstants from before your process started orInstantsmore than a century or so in the future. I don't know what we specifically want to guarantee here though.Steven Fackler at 2019-01-10 16:41:26
- What meaning does