@@ -37,7 +37,7 @@ impl Commands {
37
37
info ! ( "Adding command {}" , & command) ;
38
38
let mut state = 0 ;
39
39
40
- let mut opt_lambda_state: Option < usize > = None ;
40
+ let mut opt_lambda_state = None ;
41
41
let mut opt_final_states = vec ! [ ] ;
42
42
43
43
command
@@ -47,14 +47,14 @@ impl Commands {
47
47
. for_each ( |( i, segment) | {
48
48
if let Some ( name) = key_value_pair ( segment) {
49
49
if let Some ( lambda) = opt_lambda_state {
50
- state = add_key_value ( & name , & mut self . state_machine , lambda) ;
50
+ state = add_key_value ( & mut self . state_machine , name , lambda) ;
51
51
self . state_machine . add_next_state ( state, lambda) ;
52
52
opt_final_states. push ( state) ;
53
53
} else {
54
54
opt_final_states. push ( state) ;
55
55
state = add_space ( & mut self . state_machine , state, i) ;
56
56
opt_lambda_state = Some ( state) ;
57
- state = add_key_value ( & name , & mut self . state_machine , state) ;
57
+ state = add_key_value ( & mut self . state_machine , name , state) ;
58
58
self . state_machine
59
59
. add_next_state ( state, opt_lambda_state. unwrap ( ) ) ;
60
60
opt_final_states. push ( state) ;
@@ -66,21 +66,21 @@ impl Commands {
66
66
67
67
if segment. starts_with ( "```\n " ) && segment. ends_with ( "```" ) {
68
68
let name = & segment[ 4 ..segment. len ( ) - 3 ] ;
69
- state = add_code_segment_multi_line ( name , & mut self . state_machine , state) ;
69
+ state = add_code_segment_multi_line ( & mut self . state_machine , name , state) ;
70
70
} else if segment. starts_with ( "```" ) && segment. ends_with ( "```" ) {
71
71
let name = & segment[ 3 ..segment. len ( ) - 3 ] ;
72
72
state =
73
- add_code_segment_single_line ( name , & mut self . state_machine , state, 3 ) ;
73
+ add_code_segment_single_line ( & mut self . state_machine , name , state, 3 ) ;
74
74
} else if segment. starts_with ( "`" ) && segment. ends_with ( "`" ) {
75
75
let name = & segment[ 1 ..segment. len ( ) - 1 ] ;
76
76
state =
77
- add_code_segment_single_line ( name , & mut self . state_machine , state, 1 ) ;
77
+ add_code_segment_single_line ( & mut self . state_machine , name , state, 1 ) ;
78
78
} else if segment. starts_with ( "{" ) && segment. ends_with ( "}" ) {
79
79
let name = & segment[ 1 ..segment. len ( ) - 1 ] ;
80
- state = add_dynamic_segment ( name , & mut self . state_machine , state) ;
80
+ state = add_dynamic_segment ( & mut self . state_machine , name , state) ;
81
81
} else if segment. ends_with ( "..." ) {
82
82
let name = & segment[ ..segment. len ( ) - 3 ] ;
83
- state = add_remaining_segment ( name , & mut self . state_machine , state) ;
83
+ state = add_remaining_segment ( & mut self . state_machine , name , state) ;
84
84
} else {
85
85
segment. chars ( ) . for_each ( |ch| {
86
86
state = self . state_machine . add ( state, CharacterSet :: from_char ( ch) )
@@ -157,8 +157,8 @@ fn add_space(state_machine: &mut StateMachine, mut state: usize, i: usize) -> us
157
157
}
158
158
159
159
fn add_dynamic_segment (
160
- name : & ' static str ,
161
160
state_machine : & mut StateMachine ,
161
+ name : & ' static str ,
162
162
mut state : usize ,
163
163
) -> usize {
164
164
let mut char_set = CharacterSet :: any ( ) ;
@@ -172,8 +172,8 @@ fn add_dynamic_segment(
172
172
}
173
173
174
174
fn add_remaining_segment (
175
- name : & ' static str ,
176
175
state_machine : & mut StateMachine ,
176
+ name : & ' static str ,
177
177
mut state : usize ,
178
178
) -> usize {
179
179
let char_set = CharacterSet :: any ( ) ;
@@ -186,8 +186,8 @@ fn add_remaining_segment(
186
186
}
187
187
188
188
fn add_code_segment_multi_line (
189
- name : & ' static str ,
190
189
state_machine : & mut StateMachine ,
190
+ name : & ' static str ,
191
191
mut state : usize ,
192
192
) -> usize {
193
193
state = state_machine. add ( state, CharacterSet :: from_char ( '`' ) ) ;
@@ -220,8 +220,8 @@ fn add_code_segment_multi_line(
220
220
}
221
221
222
222
fn add_code_segment_single_line (
223
- name : & ' static str ,
224
223
state_machine : & mut StateMachine ,
224
+ name : & ' static str ,
225
225
mut state : usize ,
226
226
n_backticks : usize ,
227
227
) -> usize {
@@ -239,7 +239,7 @@ fn add_code_segment_single_line(
239
239
state
240
240
}
241
241
242
- fn add_key_value ( name : & ' static str , state_machine : & mut StateMachine , mut state : usize ) -> usize {
242
+ fn add_key_value ( state_machine : & mut StateMachine , name : & ' static str , mut state : usize ) -> usize {
243
243
name. chars ( ) . for_each ( |c| {
244
244
state = state_machine. add ( state, CharacterSet :: from_char ( c) ) ;
245
245
} ) ;
0 commit comments