Skip to content

Commit d3dd5c9

Browse files
committed
Deprecate Duration::time_fn
1 parent 8a0dc70 commit d3dd5c9

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

tests/duration.rs

+1
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ fn saturating_mul(#[case] duration: Duration, #[case] rhs: i32, #[case] expected
529529
#[rstest]
530530
#[timeout(StdDuration::from_millis(100))]
531531
fn time_fn() {
532+
#[allow(deprecated)]
532533
let (time, value) = Duration::time_fn(|| {
533534
std::thread::sleep(1.std_milliseconds());
534535
0

time/src/duration.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,10 @@ impl Duration {
11481148
/// Runs a closure, returning the duration of time it took to run. The return value of the
11491149
/// closure is provided in the second part of the tuple.
11501150
#[cfg(feature = "std")]
1151+
#[deprecated(
1152+
since = "0.3.32",
1153+
note = "extremely limited use case, not intended for benchmarking"
1154+
)]
11511155
pub fn time_fn<T>(f: impl FnOnce() -> T) -> (Self, T) {
11521156
let start = Instant::now();
11531157
let return_value = f();

0 commit comments

Comments
 (0)