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

time: Deprecate the library in the distribution #18858

Merged
merged 1 commit into from
Nov 13, 2014

Conversation

alexcrichton
Copy link
Member

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

@rust-highfive
Copy link
Collaborator

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@alexcrichton
Copy link
Member Author

cc #18585, one less crate to worry about!

@@ -135,6 +135,14 @@ impl Duration {
Duration { secs: secs, nanos: nanos as i32 }
}

/// Runs a closure, returning the duration of time it took to run the
/// closure.
pub fn span(f: ||) -> Duration {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't want to block this PR on this but I think it'd be better for span to take a closure that returns T and return a tuple of (Duration, T) to make it more general-purpose. It'd certainly make it easier to avoid the extra mutable variables that are introduced at this function's call sites in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that would definitely help out those use cases, but I figured that it would be slightly odd to have to worry about the tuple afterwards. I think it may be the right way to go though, it seemed to come up more often than I anticipated!

@ghost
Copy link

ghost commented Nov 11, 2014

As you're saying we'll tweak the interface with unboxed closures anyway, at which point we can make the suggested change.

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
bors added a commit that referenced this pull request Nov 12, 2014
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
@bors bors closed this Nov 13, 2014
@bors bors merged commit fcd05ed into rust-lang:master Nov 13, 2014
@alexcrichton alexcrichton deleted the remove-time branch November 20, 2014 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants