File tree Expand file tree Collapse file tree 1 file changed +14
-22
lines changed
Expand file tree Collapse file tree 1 file changed +14
-22
lines changed Original file line number Diff line number Diff line change 5656 // type hints.)
5757 if matches ! ( tok, Tok :: Match | Tok :: Case ) {
5858 if !self . start_of_line {
59- next = Some ( Ok ( (
60- * start,
61- Tok :: Name {
62- name : if matches ! ( tok, Tok :: Match ) {
63- "match" . to_string ( )
64- } else {
65- "case" . to_string ( )
66- } ,
67- } ,
68- * end,
69- ) ) ) ;
59+ next = Some ( Ok ( ( * start, soft_to_name ( tok) , * end) ) ) ;
7060 } else {
7161 let mut par_count = 0 ;
7262 let mut sqb_count = 0 ;
9282 first = false ;
9383 }
9484 if !seen_colon {
95- next = Some ( Ok ( (
96- * start,
97- Tok :: Name {
98- name : if matches ! ( tok, Tok :: Match ) {
99- "match" . to_string ( )
100- } else {
101- "case" . to_string ( )
102- } ,
103- } ,
104- * end,
105- ) ) ) ;
85+ next = Some ( Ok ( ( * start, soft_to_name ( tok) , * end) ) ) ;
10686 }
10787 }
10888 }
@@ -124,3 +104,15 @@ where
124104 next
125105 }
126106}
107+
108+ #[ inline]
109+ fn soft_to_name ( tok : & Tok ) -> Tok {
110+ let name = match tok {
111+ Tok :: Match => "match" ,
112+ Tok :: Case => "case" ,
113+ _ => unreachable ! ( "other tokens never reach here" ) ,
114+ } ;
115+ Tok :: Name {
116+ name : name. to_owned ( ) ,
117+ }
118+ }
You can’t perform that action at this time.
0 commit comments