@@ -508,9 +508,9 @@ pub trait RngCore {
508
508
///
509
509
/// [`RngCore`]: trait.RngCore.html
510
510
pub trait Rng : RngCore + Sized {
511
- /// Fill `dest` entirely with random bytes, where `dest` is any type
512
- /// supporting [`AsByteSliceMut`], namely slices over primitive integer
513
- /// types (`i8`, `i16`, `u32`, etc.).
511
+ /// Fill `dest` entirely with random bytes (uniform value distribution),
512
+ /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices
513
+ /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.).
514
514
///
515
515
/// On big-endian platforms this performs byte-swapping to ensure
516
516
/// portability of results from reproducible generators.
@@ -536,9 +536,9 @@ pub trait Rng: RngCore + Sized {
536
536
dest. to_le ( ) ;
537
537
}
538
538
539
- /// Fill `dest` entirely with random bytes, where `dest` is any type
540
- /// supporting [`AsByteSliceMut`], namely slices over primitive integer
541
- /// types (`i8`, `i16`, `u32`, etc.).
539
+ /// Fill `dest` entirely with random bytes (uniform value distribution),
540
+ /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices
541
+ /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.).
542
542
///
543
543
/// On big-endian platforms this performs byte-swapping to ensure
544
544
/// portability of results from reproducible generators.
@@ -867,6 +867,24 @@ impl_as_byte_slice!(i64);
867
867
#[ cfg( feature="i128_support" ) ] impl_as_byte_slice ! ( i128 ) ;
868
868
impl_as_byte_slice ! ( isize ) ;
869
869
870
+ macro_rules! impl_as_byte_slice_arrays {
871
+ ( $n: expr, ) => { } ;
872
+ ( $n: expr, $N: ident, $( $NN: ident, ) * ) => {
873
+ impl_as_byte_slice_arrays!( $n - 1 , $( $NN, ) * ) ;
874
+
875
+ impl <T > AsByteSliceMut for [ T ; $n] where [ T ] : AsByteSliceMut {
876
+ fn as_byte_slice_mut<' a>( & ' a mut self ) -> & ' a mut [ u8 ] {
877
+ self [ ..] . as_byte_slice_mut( )
878
+ }
879
+
880
+ fn to_le( & mut self ) {
881
+ self [ ..] . to_le( )
882
+ }
883
+ }
884
+ } ;
885
+ }
886
+ 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 , ) ;
887
+
870
888
/// Iterator which will generate a stream of random items.
871
889
///
872
890
/// This iterator is created via the [`gen_iter`] method on [`Rng`].
0 commit comments