mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 01:42:54 +03:00
Use built-in method
This commit is contained in:
@@ -187,14 +187,6 @@ pub(crate) fn from_macro(db: &RootDatabase, macro_def: hir::MacroDef) -> Option<
|
||||
|
||||
impl From<&'_ ast::FnDef> for FunctionSignature {
|
||||
fn from(node: &ast::FnDef) -> FunctionSignature {
|
||||
fn strip_leading_underscore(name: String) -> String {
|
||||
if name.starts_with("_") {
|
||||
name.get(1..).unwrap_or_default().to_string()
|
||||
} else {
|
||||
name
|
||||
}
|
||||
}
|
||||
|
||||
fn param_list(node: &ast::FnDef) -> (bool, Vec<String>, Vec<String>) {
|
||||
let mut res = vec![];
|
||||
let mut res_types = vec![];
|
||||
@@ -238,15 +230,17 @@ fn param_name_list(node: &ast::FnDef) -> Vec<String> {
|
||||
param_list
|
||||
.params()
|
||||
.map(|param| {
|
||||
Some(strip_leading_underscore(
|
||||
Some(
|
||||
param
|
||||
.pat()?
|
||||
.syntax()
|
||||
.descendants()
|
||||
.find_map(ast::Name::cast)?
|
||||
.text()
|
||||
.to_string(),
|
||||
))
|
||||
.to_string()
|
||||
.trim_start_matches('_')
|
||||
.into(),
|
||||
)
|
||||
})
|
||||
.map(|param| param.unwrap_or_default()),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user