@@ -386,7 +386,9 @@ pub trait SeedableRng: Sized {
386
386
}
387
387
}
388
388
389
-
389
+ // Implement `RngCore` for references to an `RngCore`.
390
+ // Force inlining all functions, so that it is up to the `RngCore`
391
+ // implementation and the optimizer to decide on inlining.
390
392
impl < ' a , R : RngCore + ?Sized > RngCore for & ' a mut R {
391
393
#[ inline( always) ]
392
394
fn next_u32 ( & mut self ) -> u32 {
@@ -398,15 +400,20 @@ impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R {
398
400
( * * self ) . next_u64 ( )
399
401
}
400
402
403
+ #[ inline( always) ]
401
404
fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
402
405
( * * self ) . fill_bytes ( dest)
403
406
}
404
407
408
+ #[ inline( always) ]
405
409
fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
406
410
( * * self ) . try_fill_bytes ( dest)
407
411
}
408
412
}
409
413
414
+ // Implement `RngCore` for boxed references to an `RngCore`.
415
+ // Force inlining all functions, so that it is up to the `RngCore`
416
+ // implementation and the optimizer to decide on inlining.
410
417
#[ cfg( feature="alloc" ) ]
411
418
impl < R : RngCore + ?Sized > RngCore for Box < R > {
412
419
#[ inline( always) ]
@@ -419,10 +426,12 @@ impl<R: RngCore + ?Sized> RngCore for Box<R> {
419
426
( * * self ) . next_u64 ( )
420
427
}
421
428
429
+ #[ inline( always) ]
422
430
fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
423
431
( * * self ) . fill_bytes ( dest)
424
432
}
425
433
434
+ #[ inline( always) ]
426
435
fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
427
436
( * * self ) . try_fill_bytes ( dest)
428
437
}
0 commit comments