diff options
author | Aaron Loucks <[email protected]> | 2020-06-03 12:26:15 +0100 |
---|---|---|
committer | Aaron Loucks <[email protected]> | 2020-06-03 12:26:15 +0100 |
commit | f06b2bcd91329fb795839a4eabd8f43aa472aeb2 (patch) | |
tree | 9642c029da5dc0bd44b36087464e2407062bf040 /crates/ra_ide/src | |
parent | 1211a46826ee8a08683e4cfe151649efd6fd90fa (diff) |
Use split1 when formatting function signature params
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index b081ecaad..ca8a6a650 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -10,7 +10,7 @@ use std::{ | |||
10 | use hir::{Docs, Documentation, HasSource, HirDisplay}; | 10 | use hir::{Docs, Documentation, HasSource, HirDisplay}; |
11 | use ra_ide_db::RootDatabase; | 11 | use ra_ide_db::RootDatabase; |
12 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; | 12 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; |
13 | use stdx::SepBy; | 13 | use stdx::{split1, SepBy}; |
14 | 14 | ||
15 | use crate::display::{generic_parameters, where_predicates}; | 15 | use crate::display::{generic_parameters, where_predicates}; |
16 | 16 | ||
@@ -210,10 +210,8 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
210 | // macro-generated functions are missing whitespace | 210 | // macro-generated functions are missing whitespace |
211 | fn fmt_param(param: ast::Param) -> String { | 211 | fn fmt_param(param: ast::Param) -> String { |
212 | let text = param.syntax().text().to_string(); | 212 | let text = param.syntax().text().to_string(); |
213 | match text.find(':') { | 213 | match split1(&text, ':') { |
214 | Some(pos) if 1 + pos < text.len() => { | 214 | Some((left, right)) => format!("{}: {}", left.trim(), right.trim()), |
215 | format!("{} {}", &text[0..1 + pos].trim(), &text[1 + pos..].trim()) | ||
216 | } | ||
217 | _ => text, | 215 | _ => text, |
218 | } | 216 | } |
219 | } | 217 | } |