@@ -397,7 +397,9 @@ pub trait SeedableRng: Sized {
397
397
}
398
398
}
399
399
400
-
400
+ // Implement `RngCore` for references to an `RngCore`.
401
+ // Force inlining all functions, so that it is up to the `RngCore`
402
+ // implementation and the optimizer to decide on inlining.
401
403
impl < ' a , R : RngCore + ?Sized > RngCore for & ' a mut R {
402
404
#[ inline( always) ]
403
405
fn next_u32 ( & mut self ) -> u32 {
@@ -409,10 +411,12 @@ impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R {
409
411
( * * self ) . next_u64 ( )
410
412
}
411
413
414
+ #[ inline( always) ]
412
415
fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
413
416
( * * self ) . fill_bytes ( dest)
414
417
}
415
418
419
+ #[ inline( always) ]
416
420
fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
417
421
( * * self ) . try_fill_bytes ( dest)
418
422
}
@@ -422,6 +426,9 @@ impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R {
422
426
}
423
427
}
424
428
429
+ // Implement `RngCore` for boxed references to an `RngCore`.
430
+ // Force inlining all functions, so that it is up to the `RngCore`
431
+ // implementation and the optimizer to decide on inlining.
425
432
#[ cfg( feature="alloc" ) ]
426
433
impl < R : RngCore + ?Sized > RngCore for Box < R > {
427
434
#[ inline( always) ]
@@ -434,10 +441,12 @@ impl<R: RngCore + ?Sized> RngCore for Box<R> {
434
441
( * * self ) . next_u64 ( )
435
442
}
436
443
444
+ #[ inline( always) ]
437
445
fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
438
446
( * * self ) . fill_bytes ( dest)
439
447
}
440
448
449
+ #[ inline( always) ]
441
450
fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
442
451
( * * self ) . try_fill_bytes ( dest)
443
452
}
0 commit comments