Skip to content

[RFC] add Duration::as_millis - #41328

Closed
durka wants to merge 3 commits into
rust-lang:masterfrom
durka:patch-39
Closed

durka wants to merge 3 commits into
rust-lang:masterfrom
durka:patch-39

Conversation

@durka

@durka durka commented Apr 16, 2017 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

r? @brson

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

@nagisa

nagisa commented Apr 16, 2017

Copy link
Copy Markdown
Member

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 T-libs-api [DEPRECATED; DO NOT USE] labels Apr 16, 2017
@durka

durka commented Apr 16, 2017

Copy link
Copy Markdown
Contributor Author

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

T-libs-api [DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants