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