Merge pull request #1415 from topecongiro/remove-duplicates
Remove duplicates
This commit is contained in:
commit
603f26d8f1
4 changed files with 18 additions and 15 deletions
11
src/expr.rs
11
src/expr.rs
|
|
@ -23,7 +23,8 @@ use lists::{write_list, itemize_list, ListFormatting, SeparatorTactic, ListTacti
|
|||
struct_lit_tactic, shape_for_tactic, struct_lit_formatting};
|
||||
use string::{StringFormat, rewrite_string};
|
||||
use utils::{extra_offset, last_line_width, wrap_str, binary_search, first_line_width,
|
||||
semicolon_for_stmt, trimmed_last_line_width, left_most_sub_expr, stmt_expr};
|
||||
semicolon_for_stmt, trimmed_last_line_width, left_most_sub_expr, stmt_expr,
|
||||
colon_spaces};
|
||||
use visitor::FmtVisitor;
|
||||
use config::{Config, IndentStyle, MultilineStyle, ControlBraceStyle};
|
||||
use comment::{FindUncommented, rewrite_comment, contains_comment, recover_comment_removed};
|
||||
|
|
@ -1891,12 +1892,8 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext,
|
|||
}
|
||||
|
||||
pub fn type_annotation_separator(config: &Config) -> &str {
|
||||
match (config.space_before_type_annotation, config.space_after_type_annotation_colon) {
|
||||
(true, true) => " : ",
|
||||
(true, false) => " :",
|
||||
(false, true) => ": ",
|
||||
(false, false) => ":",
|
||||
}
|
||||
colon_spaces(config.space_before_type_annotation,
|
||||
config.space_after_type_annotation_colon)
|
||||
}
|
||||
|
||||
fn rewrite_field(context: &RewriteContext, field: &ast::Field, shape: Shape) -> Option<String> {
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ pub fn write_list<I, T>(items: I, formatting: &ListFormatting) -> Option<String>
|
|||
let item_sep_len = if separate { sep_len } else { 0 };
|
||||
|
||||
// Item string may be multi-line. Its length (used for block comment alignment)
|
||||
// Should be only the length of the last line.
|
||||
// should be only the length of the last line.
|
||||
let item_last_line = if item.is_multiline() {
|
||||
inner_item.lines().last().unwrap_or("")
|
||||
} else {
|
||||
|
|
|
|||
10
src/types.rs
10
src/types.rs
|
|
@ -21,7 +21,7 @@ use {Shape, Spanned};
|
|||
use codemap::SpanUtils;
|
||||
use lists::{format_item_list, itemize_list, format_fn_args};
|
||||
use rewrite::{Rewrite, RewriteContext};
|
||||
use utils::{extra_offset, format_mutability, wrap_str};
|
||||
use utils::{extra_offset, format_mutability, colon_spaces, wrap_str};
|
||||
use expr::{rewrite_unary_prefix, rewrite_pair, rewrite_tuple};
|
||||
use config::TypeDensity;
|
||||
use itertools::Itertools;
|
||||
|
|
@ -346,12 +346,8 @@ fn format_function_type<'a, I>(inputs: I,
|
|||
}
|
||||
|
||||
fn type_bound_colon(context: &RewriteContext) -> &'static str {
|
||||
match (context.config.space_before_bound, context.config.space_after_bound_colon) {
|
||||
(true, true) => " : ",
|
||||
(true, false) => " :",
|
||||
(false, true) => ": ",
|
||||
(false, false) => ":",
|
||||
}
|
||||
colon_spaces(context.config.space_before_bound,
|
||||
context.config.space_after_bound_colon)
|
||||
}
|
||||
|
||||
impl Rewrite for ast::WherePredicate {
|
||||
|
|
|
|||
10
src/utils.rs
10
src/utils.rs
|
|
@ -326,6 +326,16 @@ pub fn binary_search<C, T>(mut lo: usize, mut hi: usize, callback: C) -> Option<
|
|||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn colon_spaces(before: bool, after: bool) -> &'static str {
|
||||
match (before, after) {
|
||||
(true, true) => " : ",
|
||||
(true, false) => " :",
|
||||
(false, true) => ": ",
|
||||
(false, false) => ":",
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bin_search_test() {
|
||||
let closure = |i| match i {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue