Skip to content

Commit ab78c81

Browse files
committed
Benchmarks: Consume the result in black_box.
1 parent 121b169 commit ab78c81

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

benches/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn bench_getrandom<const N: usize>(b: &mut test::Bencher) {
1313
b.iter(|| {
1414
let mut buf = [0u8; N];
1515
getrandom::getrandom(&mut buf[..]).unwrap();
16-
test::black_box(&buf);
16+
test::black_box(buf);
1717
});
1818
}
1919

@@ -26,8 +26,8 @@ fn bench_getrandom_uninit<const N: usize>(b: &mut test::Bencher) {
2626
// TODO: When the feature `maybe_uninit_as_bytes` is available, use:
2727
// since that is the shape we expect most callers to have.
2828
let mut buf: MaybeUninit<[u8; N]> = MaybeUninit::uninit();
29-
let buf = getrandom::getrandom_uninit(buf.as_bytes_mut()).unwrap();
30-
test::black_box(buf);
29+
let _ = getrandom::getrandom_uninit(buf.as_bytes_mut()).unwrap();
30+
test::black_box(unsafe { buf.assume_init() })
3131
});
3232
}
3333

0 commit comments

Comments
 (0)