Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] add Duration::as_millis #41328

Closed
wants to merge 3 commits into from
Closed

[RFC] add Duration::as_millis #41328

wants to merge 3 commits into from

Conversation

durka
Copy link
Contributor

@durka durka commented Apr 16, 2017

This PR adds a function to parallel Duration::from_millis, to get the milliseconds back out. It reduces friction when using other APIs that deal in milliseconds, while allowing Rust code to use Duration internally.

Example: I wanted to take in a Duration and pass it as milliseconds to an FFI function that expects an int, and it's messy to implement this function outside of std.

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@nagisa
Copy link
Member

nagisa commented Apr 16, 2017

I believe this was delayed so u128/i128 as a return value could be used (EDIT: no it was to_nanos). Current implementation will panic for large durations.

See also #28404 and #35868

@nagisa nagisa added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Apr 16, 2017
@durka
Copy link
Contributor Author

durka commented Apr 16, 2017

OK, from rust-lang/rfcs#1547 it basically sounds like the decision was stalemate. I'll just use chrono.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants