File tree 1 file changed +5
-10
lines changed
1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change 1
1
#![ feature( test) ]
2
+ #![ feature( maybe_uninit_as_bytes) ]
3
+
2
4
extern crate test;
3
5
4
6
use std:: mem:: MaybeUninit ;
@@ -21,16 +23,9 @@ fn bench_getrandom<const N: usize>(b: &mut test::Bencher) {
21
23
fn bench_getrandom_uninit < const N : usize > ( b : & mut test:: Bencher ) {
22
24
b. bytes = N as u64 ;
23
25
b. iter ( || {
24
- // TODO: When the feature `maybe_uninit_as_bytes` is available, use:
25
- // ```
26
- // let mut buf: MaybeUninit<[u8; N]> = MaybeUninit::uninit();
27
- // getrandom::getrandom_uninit(buf.as_bytes_mut()).unwrap();
28
- // test::black_box(unsafe { buf.assume_init() })
29
- // ```
30
- // since that is the shape we expect most callers to have.
31
- let mut buf = [ MaybeUninit :: new ( 0u8 ) ; N ] ;
32
- let buf = getrandom:: getrandom_uninit ( & mut buf[ ..] ) . unwrap ( ) ;
33
- test:: black_box ( & buf) ;
26
+ let mut buf: MaybeUninit < [ u8 ; N ] > = MaybeUninit :: uninit ( ) ;
27
+ let buf = getrandom:: getrandom_uninit ( buf. as_bytes_mut ( ) ) . unwrap ( ) ;
28
+ test:: black_box ( buf) ;
34
29
} ) ;
35
30
}
36
31
You can’t perform that action at this time.
0 commit comments