From b764c38436fcb9426eb7da3be4f5fbcd63b316f5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 28 Mar 2020 11:01:25 +0100 Subject: Start stdx This crate will hold everything to small to be worth publishing --- crates/ra_ide/src/display/function_signature.rs | 18 ++++++++---------- crates/ra_ide/src/display/short_label.rs | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'crates/ra_ide/src/display') 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 @@ //! FIXME: write short doc here -use std::fmt::{self, Display}; +use std::{ + convert::From, + fmt::{self, Display}, +}; use hir::{Docs, Documentation, HasSource, HirDisplay}; -use join_to_string::join; use ra_ide_db::RootDatabase; use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; -use std::convert::From; +use stdx::SepBy; use crate::display::{generic_parameters, where_predicates}; @@ -227,21 +229,17 @@ impl Display for FunctionSignature { } if !self.generic_parameters.is_empty() { - join(self.generic_parameters.iter()) - .separator(", ") - .surround_with("<", ">") - .to_fmt(f)?; + write!(f, "{}", self.generic_parameters.iter().sep_by(", ").surround_with("<", ">"))?; } - join(self.parameters.iter()).separator(", ").surround_with("(", ")").to_fmt(f)?; + write!(f, "{}", self.parameters.iter().sep_by(", ").surround_with("(", ")"))?; if let Some(t) = &self.ret_type { write!(f, " -> {}", t)?; } if !self.where_predicates.is_empty() { - write!(f, "\nwhere ")?; - join(self.where_predicates.iter()).separator(",\n ").to_fmt(f)?; + write!(f, "\nwhere {}", self.where_predicates.iter().sep_by(",\n "))?; } Ok(()) diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 9ffc9b980..4b081bf6c 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here -use format_buf::format; use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; +use stdx::format_to; pub(crate) trait ShortLabel { fn short_label(&self) -> Option; @@ -80,7 +80,7 @@ where let mut buf = short_label_from_node(node, prefix)?; if let Some(type_ref) = node.ascribed_type() { - format!(buf, ": {}", type_ref.syntax()); + format_to!(buf, ": {}", type_ref.syntax()); } Some(buf) -- cgit v1.2.3