std::time::Duration supports durations as long as 42 times longer than the age of the universe. However, it doesn’t have
as_millis() method, because it could overflow
u64 if the duration was longer than about a half billion years.
As it currently stands
Duration is very correct about handling millisecond precision on truly astronomical scale, but is missing ability to easily get its numeric value with precision better than a second. Users are forced to implement their own way to combine seconds + subsecond values, which is inconvenient, and a quick implementation won’t deal with handling half-billion-year durations either.
What should stdlib do?
u64and panic if the duration is longer than half billion years
u64and clamp the the duration to half billion years (return
u64::max_value()if value doesn’t fit in u64)
Errif the duration is longer than half billion years
- Don’t add the method
- Don’t know/don’t care