diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-28 11:28:31 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-28 11:28:31 +0000 |
commit | c30425dc96895117b644f29b758cee9dac36839b (patch) | |
tree | d3ccef4aa8f681cc9de29f0435ad20e87911a6ba /crates/ra_ide/src/display/function_signature.rs | |
parent | a1fea0d34ee8f3436aefd87d4c133a7ff50ffbb0 (diff) | |
parent | 311cbbdad599d51c6f08f7dd72c299f7c0128bb2 (diff) |
Merge #3753
3753: Introduce stdx crate r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/display/function_signature.rs')
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index ec1bbd5a0..b967a6816 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -1,12 +1,14 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use std::fmt::{self, Display}; | 3 | use std::{ |
4 | convert::From, | ||
5 | fmt::{self, Display}, | ||
6 | }; | ||
4 | 7 | ||
5 | use hir::{Docs, Documentation, HasSource, HirDisplay}; | 8 | use hir::{Docs, Documentation, HasSource, HirDisplay}; |
6 | use join_to_string::join; | ||
7 | use ra_ide_db::RootDatabase; | 9 | use ra_ide_db::RootDatabase; |
8 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; | 10 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; |
9 | use std::convert::From; | 11 | use stdx::SepBy; |
10 | 12 | ||
11 | use crate::display::{generic_parameters, where_predicates}; | 13 | use crate::display::{generic_parameters, where_predicates}; |
12 | 14 | ||
@@ -227,21 +229,17 @@ impl Display for FunctionSignature { | |||
227 | } | 229 | } |
228 | 230 | ||
229 | if !self.generic_parameters.is_empty() { | 231 | if !self.generic_parameters.is_empty() { |
230 | join(self.generic_parameters.iter()) | 232 | write!(f, "{}", self.generic_parameters.iter().sep_by(", ").surround_with("<", ">"))?; |
231 | .separator(", ") | ||
232 | .surround_with("<", ">") | ||
233 | .to_fmt(f)?; | ||
234 | } | 233 | } |
235 | 234 | ||
236 | join(self.parameters.iter()).separator(", ").surround_with("(", ")").to_fmt(f)?; | 235 | write!(f, "{}", self.parameters.iter().sep_by(", ").surround_with("(", ")"))?; |
237 | 236 | ||
238 | if let Some(t) = &self.ret_type { | 237 | if let Some(t) = &self.ret_type { |
239 | write!(f, " -> {}", t)?; | 238 | write!(f, " -> {}", t)?; |
240 | } | 239 | } |
241 | 240 | ||
242 | if !self.where_predicates.is_empty() { | 241 | if !self.where_predicates.is_empty() { |
243 | write!(f, "\nwhere ")?; | 242 | write!(f, "\nwhere {}", self.where_predicates.iter().sep_by(",\n "))?; |
244 | join(self.where_predicates.iter()).separator(",\n ").to_fmt(f)?; | ||
245 | } | 243 | } |
246 | 244 | ||
247 | Ok(()) | 245 | Ok(()) |