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 11use crate :: sys:: pal:: abi;
22
33pub 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 > ( ) } ;
55 if !words. is_empty ( ) {
66 unsafe {
77 abi:: sys_rand ( words. as_mut_ptr ( ) , words. len ( ) ) ;
88 }
99 }
1010
11- let mut buf = [ 0u32 ; 2 ] ;
11+ let mut buf = [ 0u8 ; 8 ] ;
1212 let len = ( pre. len ( ) + post. len ( ) + size_of :: < u32 > ( ) - 1 ) / size_of :: < u32 > ( ) ;
1313 if len != 0 {
1414 unsafe { abi:: sys_rand ( buf. as_mut_ptr ( ) , len) } ;
1515 }
1616
17- let buf = buf. map ( u32 :: to_ne_bytes) ;
17+ let buf = buf. map ( u8 :: to_ne_bytes) ;
1818 let buf = buf. as_flattened ( ) ;
1919 pre. copy_from_slice ( & buf[ ..pre. len ( ) ] ) ;
2020 post. copy_from_slice ( & buf[ pre. len ( ) ..pre. len ( ) + post. len ( ) ] ) ;
You can’t perform that action at this time.
0 commit comments