37
37
38
38
#[ cfg( feature = "alloc" ) ] extern crate alloc;
39
39
#[ cfg( feature = "std" ) ] extern crate std;
40
- #[ cfg( feature = "alloc" ) ] use alloc:: boxed:: Box ;
41
40
42
- use core:: { convert :: Infallible , fmt} ;
41
+ use core:: fmt;
43
42
43
+ mod blanket_impls;
44
44
pub mod block;
45
45
pub mod impls;
46
46
pub mod le;
@@ -207,28 +207,6 @@ pub trait TryRngCore {
207
207
/// See [`CryptoRng`] docs for more information.
208
208
pub trait TryCryptoRng : TryRngCore { }
209
209
210
- impl < R : RngCore > TryRngCore for R {
211
- type Error = Infallible ;
212
-
213
- #[ inline]
214
- fn try_next_u32 ( & mut self ) -> Result < u32 , Self :: Error > {
215
- Ok ( self . next_u32 ( ) )
216
- }
217
-
218
- #[ inline]
219
- fn try_next_u64 ( & mut self ) -> Result < u64 , Self :: Error > {
220
- Ok ( self . next_u64 ( ) )
221
- }
222
-
223
- #[ inline]
224
- fn try_fill_bytes ( & mut self , dst : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
225
- self . fill_bytes ( dst) ;
226
- Ok ( ( ) )
227
- }
228
- }
229
-
230
- impl < R : CryptoRng > TryCryptoRng for R { }
231
-
232
210
/// Wrapper around [`TryCryptoRng`] implementation which implements [`RngCore`]
233
211
/// by panicking on potential errors.
234
212
#[ derive( Debug , Default , Clone , Copy , Eq , PartialEq , Hash ) ]
@@ -401,7 +379,7 @@ pub trait SeedableRng: Sized {
401
379
/// (in prior versions this was not required).
402
380
///
403
381
/// [`rand`]: https://docs.rs/rand
404
- fn from_rng < R : RngCore > ( mut rng : R ) -> Self {
382
+ fn from_rng ( mut rng : impl RngCore ) -> Self {
405
383
let mut seed = Self :: Seed :: default ( ) ;
406
384
rng. fill_bytes ( seed. as_mut ( ) ) ;
407
385
Self :: from_seed ( seed)
@@ -410,7 +388,7 @@ pub trait SeedableRng: Sized {
410
388
/// Create a new PRNG seeded from a potentially fallible `Rng`.
411
389
///
412
390
/// See [`from_rng`][SeedableRng::from_rng] docs for more infromation.
413
- fn try_from_rng < R : TryRngCore > ( rng : & mut R ) -> Result < Self , R :: Error > {
391
+ fn try_from_rng < R : TryRngCore > ( mut rng : R ) -> Result < Self , R :: Error > {
414
392
let mut seed = Self :: Seed :: default ( ) ;
415
393
rng. try_fill_bytes ( seed. as_mut ( ) ) ?;
416
394
Ok ( Self :: from_seed ( seed) )
@@ -461,47 +439,6 @@ pub trait SeedableRng: Sized {
461
439
}
462
440
}
463
441
464
- impl < ' a , R : RngCore + ?Sized > RngCore for & ' a mut R {
465
- #[ inline( always) ]
466
- fn next_u32 ( & mut self ) -> u32 {
467
- R :: next_u32 ( self )
468
- }
469
-
470
- #[ inline( always) ]
471
- fn next_u64 ( & mut self ) -> u64 {
472
- R :: next_u64 ( self )
473
- }
474
-
475
- #[ inline( always) ]
476
- fn fill_bytes ( & mut self , dst : & mut [ u8 ] ) {
477
- R :: fill_bytes ( self , dst)
478
- }
479
- }
480
-
481
- impl < ' a , R : CryptoRng + ?Sized > CryptoRng for & ' a mut R { }
482
-
483
- #[ cfg( feature = "alloc" ) ]
484
- impl < R : RngCore + ?Sized > RngCore for Box < R > {
485
- #[ inline( always) ]
486
- fn next_u32 ( & mut self ) -> u32 {
487
- R :: next_u32 ( self )
488
- }
489
-
490
- #[ inline( always) ]
491
- fn next_u64 ( & mut self ) -> u64 {
492
- R :: next_u64 ( self )
493
- }
494
-
495
- #[ inline( always) ]
496
- fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
497
- R :: fill_bytes ( self , dest)
498
- }
499
- }
500
-
501
- #[ cfg( feature = "alloc" ) ]
502
- #[ cfg_attr( doc_cfg, doc( cfg( feature = "alloc" ) ) ) ]
503
- impl < R : CryptoRng + ?Sized > CryptoRng for Box < R > { }
504
-
505
442
/// Adapter that enables reading through a [`io::Read`](std::io::Read) from a [`RngCore`].
506
443
///
507
444
/// # Examples
0 commit comments