@@ -337,16 +337,11 @@ pub trait Rand : Sized {
337
337
/// ```rust
338
338
/// use rand::Rng;
339
339
///
340
- /// fn use_rng<R: Rng>(rng: &mut R) -> f32 {
340
+ /// fn use_rng<R: Rng + ?Sized >(rng: &mut R) -> f32 {
341
341
/// rng.gen()
342
342
/// }
343
343
/// ```
344
344
///
345
- /// Since this trait exclusively uses generic methods, it is marked `Sized`.
346
- /// Should it be necessary to support trait objects, use [`RngCore`].
347
- /// Since `Rng` extends `RngCore` and every `RngCore` implements `Rng`, usage
348
- /// of the two traits is somewhat interchangeable.
349
- ///
350
345
/// Iteration over an `Rng` can be achieved using `iter::repeat` as follows:
351
346
///
352
347
/// ```rust
@@ -373,7 +368,7 @@ pub trait Rand : Sized {
373
368
/// ```
374
369
///
375
370
/// [`RngCore`]: https://docs.rs/rand-core/0.1/rand-core/trait.RngCore.html
376
- pub trait Rng : RngCore + Sized {
371
+ pub trait Rng : RngCore {
377
372
/// Fill `dest` entirely with random bytes (uniform value distribution),
378
373
/// where `dest` is any type supporting [`AsByteSliceMut`], namely slices
379
374
/// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.).
@@ -397,7 +392,7 @@ pub trait Rng: RngCore + Sized {
397
392
/// [`fill_bytes`]: https://docs.rs/rand-core/0.1/rand-core/trait.RngCore.html#method.fill_bytes
398
393
/// [`try_fill`]: trait.Rng.html#method.try_fill
399
394
/// [`AsByteSliceMut`]: trait.AsByteSliceMut.html
400
- fn fill < T : AsByteSliceMut + ?Sized > ( & mut self , dest : & mut T ) where Self : Sized {
395
+ fn fill < T : AsByteSliceMut + ?Sized > ( & mut self , dest : & mut T ) {
401
396
self . fill_bytes ( dest. as_byte_slice_mut ( ) ) ;
402
397
dest. to_le ( ) ;
403
398
}
@@ -433,7 +428,7 @@ pub trait Rng: RngCore + Sized {
433
428
/// [`try_fill_bytes`]: https://docs.rs/rand-core/0.1/rand-core/trait.RngCore.html#method.try_fill_bytes
434
429
/// [`fill`]: trait.Rng.html#method.fill
435
430
/// [`AsByteSliceMut`]: trait.AsByteSliceMut.html
436
- fn try_fill < T : AsByteSliceMut + ?Sized > ( & mut self , dest : & mut T ) -> Result < ( ) , Error > where Self : Sized {
431
+ fn try_fill < T : AsByteSliceMut + ?Sized > ( & mut self , dest : & mut T ) -> Result < ( ) , Error > {
437
432
self . try_fill_bytes ( dest. as_byte_slice_mut ( ) ) ?;
438
433
dest. to_le ( ) ;
439
434
Ok ( ( ) )
@@ -450,7 +445,7 @@ pub trait Rng: RngCore + Sized {
450
445
/// let mut rng = thread_rng();
451
446
/// let x: i32 = rng.sample(Range::new(10, 15));
452
447
/// ```
453
- fn sample < T , D : Distribution < T > > ( & mut self , distr : D ) -> T where Self : Sized {
448
+ fn sample < T , D : Distribution < T > > ( & mut self , distr : D ) -> T {
454
449
distr. sample ( self )
455
450
}
456
451
0 commit comments