88
99//! The implementations of the `StandardUniform` distribution for integer types.
1010
11- use crate :: RngExt ;
1211use crate :: distr:: { Distribution , StandardUniform } ;
12+ use crate :: { Rng , RngExt } ;
1313#[ cfg( all( target_arch = "x86" , feature = "simd_support" ) ) ]
1414use core:: arch:: x86:: __m512i;
1515#[ cfg( target_arch = "x86" ) ]
@@ -27,35 +27,35 @@ use core::simd::*;
2727
2828impl Distribution < u8 > for StandardUniform {
2929 #[ inline]
30- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> u8 {
30+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> u8 {
3131 rng. next_u32 ( ) as u8
3232 }
3333}
3434
3535impl Distribution < u16 > for StandardUniform {
3636 #[ inline]
37- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> u16 {
37+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> u16 {
3838 rng. next_u32 ( ) as u16
3939 }
4040}
4141
4242impl Distribution < u32 > for StandardUniform {
4343 #[ inline]
44- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> u32 {
44+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> u32 {
4545 rng. next_u32 ( )
4646 }
4747}
4848
4949impl Distribution < u64 > for StandardUniform {
5050 #[ inline]
51- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> u64 {
51+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> u64 {
5252 rng. next_u64 ( )
5353 }
5454}
5555
5656impl Distribution < u128 > for StandardUniform {
5757 #[ inline]
58- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> u128 {
58+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> u128 {
5959 // Use LE; we explicitly generate one value before the next.
6060 let x = u128:: from ( rng. next_u64 ( ) ) ;
6161 let y = u128:: from ( rng. next_u64 ( ) ) ;
@@ -67,7 +67,7 @@ macro_rules! impl_int_from_uint {
6767 ( $ty: ty, $uty: ty) => {
6868 impl Distribution <$ty> for StandardUniform {
6969 #[ inline]
70- fn sample<R : RngExt + ?Sized >( & self , rng: & mut R ) -> $ty {
70+ fn sample<R : Rng + ?Sized >( & self , rng: & mut R ) -> $ty {
7171 rng. random:: <$uty>( ) as $ty
7272 }
7373 }
@@ -83,7 +83,7 @@ impl_int_from_uint! { i128, u128 }
8383macro_rules! impl_nzint {
8484 ( $ty: ty, $new: path) => {
8585 impl Distribution <$ty> for StandardUniform {
86- fn sample<R : RngExt + ?Sized >( & self , rng: & mut R ) -> $ty {
86+ fn sample<R : Rng + ?Sized >( & self , rng: & mut R ) -> $ty {
8787 loop {
8888 if let Some ( nz) = $new( rng. random( ) ) {
8989 break nz;
@@ -109,7 +109,7 @@ impl_nzint!(NonZeroI128, NonZeroI128::new);
109109#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
110110impl Distribution < __m128i > for StandardUniform {
111111 #[ inline]
112- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> __m128i {
112+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> __m128i {
113113 // NOTE: It's tempting to use the u128 impl here, but confusingly this
114114 // results in different code (return via rdx, r10 instead of rax, rdx
115115 // with u128 impl) and is much slower (+130 time).
@@ -126,7 +126,7 @@ impl Distribution<__m128i> for StandardUniform {
126126#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
127127impl Distribution < __m256i > for StandardUniform {
128128 #[ inline]
129- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> __m256i {
129+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> __m256i {
130130 let mut buf = [ 0_u8 ; core:: mem:: size_of :: < __m256i > ( ) ] ;
131131 rng. fill_bytes ( & mut buf) ;
132132 // x86 is little endian so no need for conversion
@@ -142,7 +142,7 @@ impl Distribution<__m256i> for StandardUniform {
142142) ) ]
143143impl Distribution < __m512i > for StandardUniform {
144144 #[ inline]
145- fn sample < R : RngExt + ?Sized > ( & self , rng : & mut R ) -> __m512i {
145+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> __m512i {
146146 let mut buf = [ 0_u8 ; core:: mem:: size_of :: < __m512i > ( ) ] ;
147147 rng. fill_bytes ( & mut buf) ;
148148 // x86 is little endian so no need for conversion
@@ -164,7 +164,7 @@ macro_rules! simd_impl {
164164 LaneCount <LANES >: SupportedLaneCount ,
165165 {
166166 #[ inline]
167- fn sample<R : RngExt + ?Sized >( & self , rng: & mut R ) -> Simd <$ty, LANES > {
167+ fn sample<R : Rng + ?Sized >( & self , rng: & mut R ) -> Simd <$ty, LANES > {
168168 let mut vec = Simd :: default ( ) ;
169169 rng. fill( vec. as_mut_array( ) . as_mut_slice( ) ) ;
170170 vec
0 commit comments