File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -429,16 +429,28 @@ impl<T: Clone, const N: usize> Clone for [T; N] {
429429
430430#[ unstable( feature = "random" , issue = "130703" ) ]
431431impl < T : Random , const N : usize > Random for [ T ; N ] {
432- default fn random ( source : & mut ( impl RandomSource + ?Sized ) ) -> Self {
432+ fn random ( source : & mut ( impl RandomSource + ?Sized ) ) -> Self {
433+ SpecArrayRandom :: random ( source)
434+ }
435+ }
436+
437+ #[ unstable( feature = "random" , issue = "130703" ) ]
438+ trait SpecArrayRandom : Sized {
439+ fn random < const N : usize > ( source : & mut ( impl RandomSource + ?Sized ) ) -> [ Self ; N ] ;
440+ }
441+
442+ #[ unstable( feature = "random" , issue = "130703" ) ]
443+ impl < T : Random > SpecArrayRandom for T {
444+ default fn random < const N : usize > ( source : & mut ( impl RandomSource + ?Sized ) ) -> [ T ; N ] {
433445 from_fn ( |_| T :: random ( source) )
434446 }
435447}
436448
437449macro_rules! impl_random_for_integer_array {
438450 ( $t: ty) => {
439451 #[ unstable( feature = "random" , issue = "130703" ) ]
440- impl < const N : usize > Random for [ $t ; N ] {
441- fn random( source: & mut ( impl RandomSource + ?Sized ) ) -> Self {
452+ impl SpecArrayRandom for $t {
453+ fn random< const N : usize > ( source: & mut ( impl RandomSource + ?Sized ) ) -> [ $t ; N ] {
442454 let mut buf = [ const { MaybeUninit :: <$t>:: uninit( ) } ; N ] ;
443455 // SAFETY: all elements in the buffer were initialized with
444456 // random bytes.
You can’t perform that action at this time.
0 commit comments