@@ -538,9 +538,9 @@ pub trait RngCore {
538
538
///
539
539
/// [`RngCore`]: trait.RngCore.html
540
540
pub trait Rng : RngCore + Sized {
541
- /// Fill `dest` entirely with random bytes, where `dest` is any type
542
- /// supporting [`AsByteSliceMut`], namely slices over primitive integer
543
- /// types (`i8`, `i16`, `u32`, etc.).
541
+ /// Fill `dest` entirely with random bytes (uniform value distribution),
542
+ /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices
543
+ /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.).
544
544
///
545
545
/// On big-endian platforms this performs byte-swapping to ensure
546
546
/// portability of results from reproducible generators.
@@ -566,9 +566,9 @@ pub trait Rng: RngCore + Sized {
566
566
dest. to_le ( ) ;
567
567
}
568
568
569
- /// Fill `dest` entirely with random bytes, where `dest` is any type
570
- /// supporting [`AsByteSliceMut`], namely slices over primitive integer
571
- /// types (`i8`, `i16`, `u32`, etc.).
569
+ /// Fill `dest` entirely with random bytes (uniform value distribution),
570
+ /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices
571
+ /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.).
572
572
///
573
573
/// On big-endian platforms this performs byte-swapping to ensure
574
574
/// portability of results from reproducible generators.
@@ -880,6 +880,24 @@ impl_as_byte_slice!(i64);
880
880
#[ cfg( feature="i128_support" ) ] impl_as_byte_slice ! ( i128 ) ;
881
881
impl_as_byte_slice ! ( isize ) ;
882
882
883
+ macro_rules! impl_as_byte_slice_arrays {
884
+ ( $n: expr, ) => { } ;
885
+ ( $n: expr, $N: ident, $( $NN: ident, ) * ) => {
886
+ impl_as_byte_slice_arrays!( $n - 1 , $( $NN, ) * ) ;
887
+
888
+ impl <T > AsByteSliceMut for [ T ; $n] where [ T ] : AsByteSliceMut {
889
+ fn as_byte_slice_mut<' a>( & ' a mut self ) -> & ' a mut [ u8 ] {
890
+ self [ ..] . as_byte_slice_mut( )
891
+ }
892
+
893
+ fn to_le( & mut self ) {
894
+ self [ ..] . to_le( )
895
+ }
896
+ }
897
+ } ;
898
+ }
899
+ impl_as_byte_slice_arrays ! ( 32 , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , N , ) ;
900
+
883
901
/// Iterator which will generate a stream of random items.
884
902
///
885
903
/// This iterator is created via the [`gen_iter`] method on [`Rng`].
0 commit comments