File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
library/std/src/sys/random Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: sys:: pal:: abi;
2
2
3
3
pub fn fill_bytes ( bytes : & mut [ u8 ] ) {
4
- let ( pre, words, post) = unsafe { bytes. align_to_mut :: < u32 > ( ) } ;
4
+ let ( pre, words, post) = unsafe { bytes. align_to_mut :: < u8 > ( ) } ;
5
5
if !words. is_empty ( ) {
6
6
unsafe {
7
7
abi:: sys_rand ( words. as_mut_ptr ( ) , words. len ( ) ) ;
8
8
}
9
9
}
10
10
11
- let mut buf = [ 0u32 ; 2 ] ;
11
+ let mut buf = [ 0u8 ; 8 ] ;
12
12
let len = ( pre. len ( ) + post. len ( ) + size_of :: < u32 > ( ) - 1 ) / size_of :: < u32 > ( ) ;
13
13
if len != 0 {
14
14
unsafe { abi:: sys_rand ( buf. as_mut_ptr ( ) , len) } ;
15
15
}
16
16
17
- let buf = buf. map ( u32 :: to_ne_bytes) ;
17
+ let buf = buf. map ( u8 :: to_ne_bytes) ;
18
18
let buf = buf. as_flattened ( ) ;
19
19
pre. copy_from_slice ( & buf[ ..pre. len ( ) ] ) ;
20
20
post. copy_from_slice ( & buf[ pre. len ( ) ..pre. len ( ) + post. len ( ) ] ) ;
You can’t perform that action at this time.
0 commit comments