File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 51
51
//! [`fill_bytes`]: RngCore::fill_bytes
52
52
53
53
use core:: convert:: AsRef ;
54
- use core:: fmt;
54
+ use core:: { fmt, ptr } ;
55
55
use { RngCore , CryptoRng , SeedableRng , Error } ;
56
56
use impls:: { fill_via_u32_chunks, fill_via_u64_chunks} ;
57
57
@@ -183,7 +183,8 @@ where <R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>
183
183
let read_u64 = |results : & [ u32 ] , index| {
184
184
if cfg ! ( any( target_arch = "x86" , target_arch = "x86_64" ) ) {
185
185
// requires little-endian CPU supporting unaligned reads:
186
- unsafe { * ( & results[ index] as * const u32 as * const u64 ) }
186
+ let ptr: * const u64 = & results[ index..index+1 ] as * const [ u32 ] as * const u32 as * const u64 ;
187
+ unsafe { ptr:: read_unaligned ( ptr) }
187
188
} else {
188
189
let x = u64:: from ( results[ index] ) ;
189
190
let y = u64:: from ( results[ index + 1 ] ) ;
You can’t perform that action at this time.
0 commit comments