-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Duration: methods to extract non-integral content #18855
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
Comments
What's the general precedent here? |
cc @brson |
My use case was when I had a duration of time and I wanted to print out how many "things per second" happened in that duration of time. Given a number of "things", I would ideally use a I'm not sure that we want to s/i64/f64/ in the API, just a thought of mine that perhaps it could be a little easier to extract the float-wise number of units. |
Let's make |
I don't like separate variants. If we can't make
and use macros:
|
Yesterday we were happy with
Then, implement trait for both i64 and f64:
And finally use it:
In general, it seems to be a more elegant solution. Though, a single |
This commit deprecates the entire libtime library in favor of the externally-provided libtime in the rust-lang organization. Users of the `libtime` crate as-is today should add this to their Cargo manifests: [dependencies.time] git = "https://github.com/rust-lang/time" To implement this transition, a new function `Duration::span` was added to the `std::time::Duration` time. This function takes a closure and then returns the duration of time it took that closure to execute. This interface will likely improve with `FnOnce` unboxed closures as moving in and out will be a little easier. Due to the deprecation of the in-tree crate, this is a: [breaking-change] cc rust-lang#18855, some of the conversions in the `src/test/bench` area may have been a little nicer with that implemented
This commit deprecates the entire libtime library in favor of the externally-provided libtime in the rust-lang organization. Users of the `libtime` crate as-is today should add this to their Cargo manifests: [dependencies.time] git = "https://github.com/rust-lang/time" To implement this transition, a new function `Duration::span` was added to the `std::time::Duration` time. This function takes a closure and then returns the duration of time it took that closure to execute. This interface will likely improve with `FnOnce` unboxed closures as moving in and out will be a little easier. Due to the deprecation of the in-tree crate, this is a: [breaking-change] cc #18855, some of the conversions in the `src/test/bench` area may have been a little nicer with that implemented
The |
internal: Migrate `if let` replacement assists to `SyntaxEditor`
Right now,
Duration::num_seconds
and friends returni64
values, which means you get the number of whole seconds included in the duration. But it's often useful to get fractional values as well.It's unclear whether the methods should simply be changed to yield
f64
values, or whether we should have separate variants.The text was updated successfully, but these errors were encountered: