Closed
Description
std::time
currently contains:
impl Duration {
/// Runs a closure, returning the duration of time it took to run the
/// closure.
#[unstable(feature = "duration_span",
reason = "unsure if this is the right API or whether it should \
wait for a more general \"moment in time\" \
abstraction")]
pub fn span<F>(f: F) -> Duration where F: FnOnce() {
let start = SteadyTime::now();
f();
&SteadyTime::now() - &start
}
}
I’d like to stabilize this method unchanged. Even if a "moment in time" abstraction exists, doing the let start = now(); do stuff; now() - start
dance gets tedious very quickly and a closure-based Duration::span
method would still be valuable.
Metadata
Metadata
Assignees
Labels
No labels