std: add Duration::as_millis#28404
Conversation
|
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
This can overflow, so should probably return an Option instead.
5e4ea3e to
600dc8e
Compare
|
@sfackler updated to use Option |
|
The RFC for
As a result, I think that accessor methods like this may wish to go through an RFC. For example I would have questions along the lines of:
|
|
@alexcrichton This is motivated by balancing the accessors with the constructors: there exists But I definitely can see how the color of this shed could be rainbow, and I can write a function to do the same thing for my needs. |
|
I understand the motivation, but I don't personally think that it's strong enough to bypass an RFC when the original RFC explicitly avoided this. |
Following "do whatever is easiest", this was about the same amount of work to implement vs write up an RFC.
Motivation: there already exists a
Duration::from_millisfunction, but no mirrorDuration::as_millis. Milliseconds are commonly desired in programming, and the lack ofas_millisfeels unbalanced.