@@ -48,8 +48,10 @@ impl BuiltIn {
48
48
. for_each ( |mut s| case_correct ( & mut s, word_token. case ( ) ) ) ;
49
49
Some ( corrections)
50
50
}
51
+ }
51
52
52
- #[ cfg( feature = "dict" ) ]
53
+ #[ cfg( feature = "dict" ) ]
54
+ impl BuiltIn {
53
55
// Not using `Status` to avoid the allocations
54
56
fn correct_with_dict ( & self , word : & str ) -> Option < & ' static [ & ' static str ] > {
55
57
if typos_dict:: WORD_RANGE . contains ( & word. len ( ) ) {
@@ -58,13 +60,17 @@ impl BuiltIn {
58
60
None
59
61
}
60
62
}
63
+ }
61
64
62
- #[ cfg( not( feature = "dict" ) ) ]
65
+ #[ cfg( not( feature = "dict" ) ) ]
66
+ impl BuiltIn {
63
67
fn correct_with_dict ( & self , _word : & str ) -> Option < & ' static [ & ' static str ] > {
64
68
None
65
69
}
70
+ }
66
71
67
- #[ cfg( feature = "vars" ) ]
72
+ #[ cfg( feature = "vars" ) ]
73
+ impl BuiltIn {
68
74
fn chain_with_vars ( & self , corrections : & ' static [ & ' static str ] ) -> Status < ' static > {
69
75
let mut chained: Vec < _ > = corrections
70
76
. iter ( )
@@ -84,12 +90,6 @@ impl BuiltIn {
84
90
Status :: Corrections ( chained)
85
91
}
86
92
87
- #[ cfg( not( feature = "vars" ) ) ]
88
- fn chain_with_vars ( & self , corrections : & ' static [ & ' static str ] ) -> Status < ' static > {
89
- Status :: Corrections ( corrections. iter ( ) . map ( |c| Cow :: Borrowed ( * c) ) . collect ( ) )
90
- }
91
-
92
- #[ cfg( feature = "vars" ) ]
93
93
fn correct_with_vars ( & self , word : & str ) -> Option < Status < ' static > > {
94
94
if typos_vars:: WORD_RANGE . contains ( & word. len ( ) ) {
95
95
map_lookup ( & typos_vars:: VARS_DICTIONARY , word)
@@ -99,12 +99,6 @@ impl BuiltIn {
99
99
}
100
100
}
101
101
102
- #[ cfg( not( feature = "vars" ) ) ]
103
- fn correct_with_vars ( & self , _word : & str ) -> Option < Status < ' static > > {
104
- None
105
- }
106
-
107
- #[ cfg( feature = "vars" ) ]
108
102
fn select_variant (
109
103
& self ,
110
104
vars : & ' static [ ( u8 , & ' static typos_vars:: VariantsMap ) ] ,
@@ -148,6 +142,17 @@ impl BuiltIn {
148
142
}
149
143
}
150
144
145
+ #[ cfg( not( feature = "vars" ) ) ]
146
+ impl BuiltIn {
147
+ fn chain_with_vars ( & self , corrections : & ' static [ & ' static str ] ) -> Status < ' static > {
148
+ Status :: Corrections ( corrections. iter ( ) . map ( |c| Cow :: Borrowed ( * c) ) . collect ( ) )
149
+ }
150
+
151
+ fn correct_with_vars ( & self , _word : & str ) -> Option < Status < ' static > > {
152
+ None
153
+ }
154
+ }
155
+
151
156
impl typos:: Dictionary for BuiltIn {
152
157
fn correct_ident < ' s , ' w > ( & ' s self , ident : typos:: tokens:: Identifier < ' w > ) -> Option < Status < ' s > > {
153
158
BuiltIn :: correct_ident ( self , ident)
0 commit comments