diff --git a/tests/duration.rs b/tests/duration.rs index 194b67e3f..ef0064fa4 100644 --- a/tests/duration.rs +++ b/tests/duration.rs @@ -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 diff --git a/time/src/duration.rs b/time/src/duration.rs index ef4e5cbfb..1aeb9674a 100644 --- a/time/src/duration.rs +++ b/time/src/duration.rs @@ -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(f: impl FnOnce() -> T) -> (Self, T) { let start = Instant::now(); let return_value = f();