@@ -383,28 +383,40 @@ impl_fill!(i8, i16, i32, i64, isize,);
383383#[ cfg( not( target_os = "emscripten" ) ) ]
384384impl_fill ! ( i128 ) ;
385385
386- macro_rules! impl_fill_arrays {
387- ( $n: expr, ) => { } ;
388- ( $n: expr, $N: ident) => {
389- impl <T > Fill for [ T ; $n] where [ T ] : Fill {
390- fn try_fill<R : Rng + ?Sized >( & mut self , rng: & mut R ) -> Result <( ) , Error > {
391- self [ ..] . try_fill( rng)
392- }
393- }
394- } ;
395- ( $n: expr, $N: ident, $( $NN: ident, ) * ) => {
396- impl_fill_arrays!( $n, $N) ;
397- impl_fill_arrays!( $n - 1 , $( $NN, ) * ) ;
398- } ;
399- ( !div $n: expr, ) => { } ;
400- ( !div $n: expr, $N: ident, $( $NN: ident, ) * ) => {
401- impl_fill_arrays!( $n, $N) ;
402- impl_fill_arrays!( !div $n / 2 , $( $NN, ) * ) ;
403- } ;
386+ #[ cfg( feature = "const_generics" ) ]
387+ impl < T , const N : usize > Fill for [ T ; N ] where [ T ] : Fill {
388+ fn try_fill < R : Rng + ?Sized > ( & mut self , rng : & mut R ) -> Result < ( ) , Error > {
389+ self [ ..] . try_fill ( rng)
390+ }
404391}
392+
393+ #[ cfg( not( feature = "const_generics" ) ) ]
405394#[ rustfmt:: skip]
406- impl_fill_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 , N , ) ;
407- impl_fill_arrays ! ( !div 4096 , N , N , N , N , N , N , N , ) ;
395+ mod impls {
396+ use super :: * ;
397+
398+ macro_rules! impl_fill_arrays {
399+ ( $n: expr, ) => { } ;
400+ ( $n: expr, $N: ident) => {
401+ impl <T > Fill for [ T ; $n] where [ T ] : Fill {
402+ fn try_fill<R : Rng + ?Sized >( & mut self , rng: & mut R ) -> Result <( ) , Error > {
403+ self [ ..] . try_fill( rng)
404+ }
405+ }
406+ } ;
407+ ( $n: expr, $N: ident, $( $NN: ident, ) * ) => {
408+ impl_fill_arrays!( $n, $N) ;
409+ impl_fill_arrays!( $n - 1 , $( $NN, ) * ) ;
410+ } ;
411+ ( !div $n: expr, ) => { } ;
412+ ( !div $n: expr, $N: ident, $( $NN: ident, ) * ) => {
413+ impl_fill_arrays!( $n, $N) ;
414+ impl_fill_arrays!( !div $n / 2 , $( $NN, ) * ) ;
415+ } ;
416+ }
417+ impl_fill_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 , N , ) ;
418+ impl_fill_arrays ! ( !div 4096 , N , N , N , N , N , N , N , ) ;
419+ }
408420
409421#[ cfg( test) ]
410422mod test {
0 commit comments