File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -66,18 +66,19 @@ where
6666 fn next ( & mut self ) -> Option < Self :: Item > {
6767 let Self { vals, state } = self ;
6868 match state {
69- PermutationState :: Start { k : 0 } => {
70- * state = PermutationState :: End ;
71- Some ( Vec :: new ( ) )
72- }
7369 & mut PermutationState :: Start { k } => {
74- vals. prefill ( k) ;
75- if vals. len ( ) != k {
70+ if k == 0 {
7671 * state = PermutationState :: End ;
77- return None ;
72+ Some ( Vec :: new ( ) )
73+ } else {
74+ vals. prefill ( k) ;
75+ if vals. len ( ) != k {
76+ * state = PermutationState :: End ;
77+ return None ;
78+ }
79+ * state = PermutationState :: Buffered { k, min_n : k } ;
80+ Some ( vals[ 0 ..k] . to_vec ( ) )
7881 }
79- * state = PermutationState :: Buffered { k, min_n : k } ;
80- Some ( vals[ 0 ..k] . to_vec ( ) )
8182 }
8283 PermutationState :: Buffered { ref k, min_n } => {
8384 if vals. get_next ( ) {
You can’t perform that action at this time.
0 commit comments