Skip to content

Commit

Permalink
Deprecate Duration::time_fn
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Feb 1, 2024
1 parent 8a0dc70 commit d3dd5c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ fn saturating_mul(#[case] duration: Duration, #[case] rhs: i32, #[case] expected
#[rstest]
#[timeout(StdDuration::from_millis(100))]
fn time_fn() {
#[allow(deprecated)]
let (time, value) = Duration::time_fn(|| {
std::thread::sleep(1.std_milliseconds());
0
Expand Down
4 changes: 4 additions & 0 deletions time/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,10 @@ impl Duration {
/// Runs a closure, returning the duration of time it took to run. The return value of the
/// closure is provided in the second part of the tuple.
#[cfg(feature = "std")]
#[deprecated(
since = "0.3.32",
note = "extremely limited use case, not intended for benchmarking"
)]
pub fn time_fn<T>(f: impl FnOnce() -> T) -> (Self, T) {
let start = Instant::now();
let return_value = f();
Expand Down

0 comments on commit d3dd5c9

Please sign in to comment.