Implement ptr_vec_to_ref_vec()
This commit is contained in:
parent
7e309a4ad8
commit
8e5c76094d
15
src/expr.rs
15
src/expr.rs
@ -33,7 +33,7 @@ use string::{rewrite_string, StringFormat};
|
||||
use types::{can_be_overflowed_type, rewrite_path, PathContext};
|
||||
use utils::{binary_search, colon_spaces, contains_skip, extra_offset, first_line_width,
|
||||
inner_attributes, last_line_extendable, last_line_width, left_most_sub_expr, mk_sp,
|
||||
outer_attributes, paren_overhead, semicolon_for_stmt, stmt_expr,
|
||||
outer_attributes, paren_overhead, ptr_vec_to_ref_vec, semicolon_for_stmt, stmt_expr,
|
||||
trimmed_last_line_width, wrap_str};
|
||||
use vertical::rewrite_with_alignment;
|
||||
use visitor::FmtVisitor;
|
||||
@ -85,7 +85,7 @@ pub fn format_expr(
|
||||
rewrite_call_with_binary_search(
|
||||
context,
|
||||
&**callee,
|
||||
&args.iter().map(|x| &**x).collect::<Vec<_>>()[..],
|
||||
&ptr_vec_to_ref_vec(&args),
|
||||
inner_span,
|
||||
shape,
|
||||
)
|
||||
@ -112,12 +112,9 @@ pub fn format_expr(
|
||||
expr.span,
|
||||
shape,
|
||||
),
|
||||
ast::ExprKind::Tup(ref items) => rewrite_tuple(
|
||||
context,
|
||||
&items.iter().map(|x| &**x).collect::<Vec<_>>()[..],
|
||||
expr.span,
|
||||
shape,
|
||||
),
|
||||
ast::ExprKind::Tup(ref items) => {
|
||||
rewrite_tuple(context, &ptr_vec_to_ref_vec(&items), expr.span, shape)
|
||||
}
|
||||
ast::ExprKind::If(..) |
|
||||
ast::ExprKind::IfLet(..) |
|
||||
ast::ExprKind::ForLoop(..) |
|
||||
@ -2037,7 +2034,7 @@ pub fn rewrite_call(
|
||||
rewrite_call_inner(
|
||||
context,
|
||||
callee,
|
||||
&args.iter().map(|x| &**x).collect::<Vec<_>>(),
|
||||
&ptr_vec_to_ref_vec(&args),
|
||||
span,
|
||||
shape,
|
||||
context.config.fn_call_width(),
|
||||
|
@ -727,7 +727,7 @@ impl Rewrite for ast::Ty {
|
||||
}
|
||||
ast::TyKind::Tup(ref items) => rewrite_tuple(
|
||||
context,
|
||||
&items.iter().map(|x| &**x).collect::<Vec<_>>()[..],
|
||||
&::utils::ptr_vec_to_ref_vec(&items),
|
||||
self.span,
|
||||
shape,
|
||||
),
|
||||
|
@ -11,7 +11,7 @@
|
||||
use std::borrow::Cow;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use syntax::abi;
|
||||
use syntax::{abi, ptr};
|
||||
use syntax::ast::{self, Attribute, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind,
|
||||
Path, Visibility};
|
||||
use syntax::codemap::{BytePos, Span, NO_EXPANSION};
|
||||
@ -97,6 +97,12 @@ pub fn format_abi(abi: abi::Abi, explicit_abi: bool) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
// Transform `Vec<syntax::ptr::P<T>>` into `Vec<&T>`
|
||||
pub fn ptr_vec_to_ref_vec<T>(vec: &[ptr::P<T>]) -> Vec<&T> {
|
||||
vec.iter().map(|x| &**x).collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn filter_attributes(attrs: &[ast::Attribute], style: ast::AttrStyle) -> Vec<ast::Attribute> {
|
||||
attrs
|
||||
|
Loading…
x
Reference in New Issue
Block a user