Replace folds with for loops
This commit is contained in:
parent
b706ae22dc
commit
fdf1136e79
@ -311,18 +311,17 @@ fn change_visibility(&self, record_fields: Vec<SyntaxNode>) -> Option<Vec<ast::I
|
|||||||
let (body_items, mut replacements, record_field_parents, impls) =
|
let (body_items, mut replacements, record_field_parents, impls) =
|
||||||
get_replacements_for_visibilty_change(self.body_items.clone(), false);
|
get_replacements_for_visibilty_change(self.body_items.clone(), false);
|
||||||
|
|
||||||
let impl_items = impls.into_iter().fold(Vec::new(), |mut impl_items, x| {
|
let mut impl_items = Vec::new();
|
||||||
let mut this_impl_items =
|
for impl_ in impls {
|
||||||
x.syntax().descendants().fold(Vec::new(), |mut this_impl_items, x| {
|
let mut this_impl_items = Vec::new();
|
||||||
if let Some(item) = ast::Item::cast(x) {
|
for node in impl_.syntax().descendants() {
|
||||||
this_impl_items.push(item);
|
if let Some(item) = ast::Item::cast(node) {
|
||||||
}
|
this_impl_items.push(item);
|
||||||
return this_impl_items;
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
impl_items.append(&mut this_impl_items);
|
impl_items.append(&mut this_impl_items);
|
||||||
return impl_items;
|
}
|
||||||
});
|
|
||||||
|
|
||||||
let (_, mut impl_item_replacements, _, _) =
|
let (_, mut impl_item_replacements, _, _) =
|
||||||
get_replacements_for_visibilty_change(impl_items, true);
|
get_replacements_for_visibilty_change(impl_items, true);
|
||||||
|
@ -456,10 +456,10 @@ fn fn_args(
|
|||||||
/// assert_eq!(names, expected);
|
/// assert_eq!(names, expected);
|
||||||
/// ```
|
/// ```
|
||||||
fn deduplicate_arg_names(arg_names: &mut Vec<String>) {
|
fn deduplicate_arg_names(arg_names: &mut Vec<String>) {
|
||||||
let arg_name_counts = arg_names.iter().fold(FxHashMap::default(), |mut m, name| {
|
let mut arg_name_counts = FxHashMap::default();
|
||||||
*m.entry(name).or_insert(0) += 1;
|
for name in arg_names.iter() {
|
||||||
m
|
*arg_name_counts.entry(name).or_insert(0) += 1;
|
||||||
});
|
}
|
||||||
let duplicate_arg_names: FxHashSet<String> = arg_name_counts
|
let duplicate_arg_names: FxHashSet<String> = arg_name_counts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(_, count)| *count >= 2)
|
.filter(|(_, count)| *count >= 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user