diff options
author | Yuki Kodama <[email protected]> | 2020-05-24 15:43:44 +0100 |
---|---|---|
committer | Yuki Kodama <[email protected]> | 2020-05-25 17:06:25 +0100 |
commit | 408d04764cd00a9f24fce15198ec26d7c74fb4d6 (patch) | |
tree | 51261555a0a0a9b7e1799f27bcbf87cb10966937 /crates | |
parent | 378bfc3c8f1c63f44f972e11c9de00f9733b13c0 (diff) |
Use built-in method
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index 4f054398a..fabc78f14 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -187,14 +187,6 @@ 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 | |||
198 | fn param_list(node: &ast::FnDef) -> (bool, Vec<String>, Vec<String>) { | 190 | fn param_list(node: &ast::FnDef) -> (bool, Vec<String>, Vec<String>) { |
199 | let mut res = vec![]; | 191 | let mut res = vec![]; |
200 | let mut res_types = vec![]; | 192 | let mut res_types = vec![]; |
@@ -238,15 +230,17 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
238 | param_list | 230 | param_list |
239 | .params() | 231 | .params() |
240 | .map(|param| { | 232 | .map(|param| { |
241 | Some(strip_leading_underscore( | 233 | Some( |
242 | param | 234 | param |
243 | .pat()? | 235 | .pat()? |
244 | .syntax() | 236 | .syntax() |
245 | .descendants() | 237 | .descendants() |
246 | .find_map(ast::Name::cast)? | 238 | .find_map(ast::Name::cast)? |
247 | .text() | 239 | .text() |
248 | .to_string(), | 240 | .to_string() |
249 | )) | 241 | .trim_start_matches('_') |
242 | .into(), | ||
243 | ) | ||
250 | }) | 244 | }) |
251 | .map(|param| param.unwrap_or_default()), | 245 | .map(|param| param.unwrap_or_default()), |
252 | ); | 246 | ); |