diff options
author | Yuki Kodama <[email protected]> | 2020-05-24 10:09:42 +0100 |
---|---|---|
committer | Yuki Kodama <[email protected]> | 2020-05-25 17:06:25 +0100 |
commit | 6c676909dd94f48ab1e85427071b508f104f360f (patch) | |
tree | 5a1bd28dbb15469541ce1f88d489b14e6d13afe1 /crates/ra_ide/src/display/function_signature.rs | |
parent | 3c2c8d7e5f7887351bf8e475f441609527679e5f (diff) |
Strip leading underscore
Diffstat (limited to 'crates/ra_ide/src/display/function_signature.rs')
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index 9572debd8..4f054398a 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -187,6 +187,14 @@ impl FunctionSignature { | |||
187 | 187 | ||
188 | impl From<&'_ ast::FnDef> for FunctionSignature { | 188 | impl From<&'_ ast::FnDef> for FunctionSignature { |
189 | fn from(node: &ast::FnDef) -> FunctionSignature { | 189 | fn from(node: &ast::FnDef) -> FunctionSignature { |
190 | fn strip_leading_underscore(name: String) -> String { | ||
191 | if name.starts_with("_") { | ||
192 | name.get(1..).unwrap_or_default().to_string() | ||
193 | } else { | ||
194 | name | ||
195 | } | ||
196 | } | ||
197 | |||
190 | fn param_list(node: &ast::FnDef) -> (bool, Vec<String>, Vec<String>) { | 198 | fn param_list(node: &ast::FnDef) -> (bool, Vec<String>, Vec<String>) { |
191 | let mut res = vec![]; | 199 | let mut res = vec![]; |
192 | let mut res_types = vec![]; | 200 | let mut res_types = vec![]; |
@@ -230,7 +238,7 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
230 | param_list | 238 | param_list |
231 | .params() | 239 | .params() |
232 | .map(|param| { | 240 | .map(|param| { |
233 | Some( | 241 | Some(strip_leading_underscore( |
234 | param | 242 | param |
235 | .pat()? | 243 | .pat()? |
236 | .syntax() | 244 | .syntax() |
@@ -238,7 +246,7 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
238 | .find_map(ast::Name::cast)? | 246 | .find_map(ast::Name::cast)? |
239 | .text() | 247 | .text() |
240 | .to_string(), | 248 | .to_string(), |
241 | ) | 249 | )) |
242 | }) | 250 | }) |
243 | .map(|param| param.unwrap_or_default()), | 251 | .map(|param| param.unwrap_or_default()), |
244 | ); | 252 | ); |