File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,13 @@ macro_rules! rng_core_transmute {
177
177
}
178
178
179
179
rng_core ! ( u8 , u16 , u32 ) ;
180
+
181
+ // Alignment of these types must be a multiple of mem::align_of::<32>()
180
182
rng_core_large ! ( u64 , u128 ) ;
183
+
184
+ // A and B must have the same alignment
185
+ // rng_core_transmute!(A = B)
186
+ // assert!(mem::align_of::<A>() == mem::align_of::<B>())
181
187
rng_core_transmute ! (
182
188
i8 = u8 ,
183
189
i16 = u16 ,
@@ -222,10 +228,12 @@ impl rand_core::RngCore for Rng {
222
228
dest : & mut [ u8 ] ,
223
229
) -> Result < ( ) , rand_core:: Error > {
224
230
self . fill ( dest) . map_err ( |e| {
225
- core:: num:: NonZeroU32 :: new ( e as u32 )
226
- // This should never fail as long as no enum variant is equal to 0
227
- . expect ( "Internal hal error" )
228
- . into ( )
231
+ core:: num:: NonZeroU32 :: new (
232
+ rand_core:: Error :: CUSTOM_START + e as u32 ,
233
+ )
234
+ // This should never fail as long as no enum variant is equal to 0
235
+ . expect ( "Internal hal error" )
236
+ . into ( )
229
237
} )
230
238
}
231
239
}
You can’t perform that action at this time.
0 commit comments