File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,9 @@ pub trait ArrayOrVecHelper: BorrowMut<[usize]> {
108108 where
109109 I :: Item : Clone ;
110110
111- fn from_fn < T , F : Fn ( usize ) -> T > ( k : Self :: Length , f : F ) -> Self :: Item < T > ;
111+ // TODO if only ever used to index into LazyBuffer, specialize to
112+ // extract_from_fn(Self::Length, Fn(usize) -> usize, &LazyBuffer) -> Item<T>?
113+ fn item_from_fn < T , F : Fn ( usize ) -> T > ( len : Self :: Length , f : F ) -> Self :: Item < T > ;
112114
113115 fn len ( & self ) -> Self :: Length ;
114116}
@@ -124,8 +126,8 @@ impl ArrayOrVecHelper for Vec<usize> {
124126 pool. get_at ( self )
125127 }
126128
127- fn from_fn < T , F : Fn ( usize ) -> T > ( k : Self :: Length , f : F ) -> Self :: Item < T > {
128- ( 0 ..k ) . map ( f) . collect ( )
129+ fn item_from_fn < T , F : Fn ( usize ) -> T > ( len : Self :: Length , f : F ) -> Self :: Item < T > {
130+ ( 0 ..len ) . map ( f) . collect ( )
129131 }
130132
131133 fn len ( & self ) -> Self :: Length {
@@ -144,7 +146,7 @@ impl<const K: usize> ArrayOrVecHelper for [usize; K] {
144146 pool. get_array ( * self )
145147 }
146148
147- fn from_fn < T , F : Fn ( usize ) -> T > ( _k : Self :: Length , f : F ) -> Self :: Item < T > {
149+ fn item_from_fn < T , F : Fn ( usize ) -> T > ( _len : Self :: Length , f : F ) -> Self :: Item < T > {
148150 std:: array:: from_fn ( f)
149151 }
150152
Original file line number Diff line number Diff line change @@ -84,12 +84,12 @@ where
8484 min_n : k. value ( ) ,
8585 } ;
8686 }
87- Some ( Idx :: from_fn ( k, |i| vals[ i] . clone ( ) ) )
87+ Some ( Idx :: item_from_fn ( k, |i| vals[ i] . clone ( ) ) )
8888 }
8989 PermutationState :: Buffered { k, min_n } => {
9090 if vals. get_next ( ) {
9191 // TODO This is ugly. Maybe working on indices is better?
92- let item = Idx :: from_fn ( * k, |i| {
92+ let item = Idx :: item_from_fn ( * k, |i| {
9393 vals[ if i == k. value ( ) - 1 { * min_n } else { i } ] . clone ( )
9494 } ) ;
9595 * min_n += 1 ;
@@ -106,7 +106,7 @@ where
106106 return None ;
107107 }
108108 }
109- let item = Idx :: from_fn ( * k, |i| vals[ indices[ i] ] . clone ( ) ) ;
109+ let item = Idx :: item_from_fn ( * k, |i| vals[ indices[ i] ] . clone ( ) ) ;
110110 * state = PermutationState :: Loaded {
111111 indices,
112112 cycles,
@@ -120,7 +120,7 @@ where
120120 * state = PermutationState :: End ;
121121 return None ;
122122 }
123- Some ( Idx :: from_fn ( * k, |i| vals[ indices[ i] ] . clone ( ) ) )
123+ Some ( Idx :: item_from_fn ( * k, |i| vals[ indices[ i] ] . clone ( ) ) )
124124 }
125125 PermutationState :: End => None ,
126126 }
You can’t perform that action at this time.
0 commit comments