// We force to use block for the body of the closure for certain kinds of expressions.
if is_block_closure_forced(context, body) {
- return rewrite_closure_with_block(body, &prefix, context, body_shape).and_then(
+ return rewrite_closure_with_block(body, &prefix, context, body_shape).map(
|body_str| {
match fn_decl.output {
ast::FnRetTy::Default(..) if body_str.lines().count() <= 7 => {
// closure. However, if the closure has a return type, then we must
// keep the blocks.
match rewrite_closure_expr(body, &prefix, context, shape) {
- Some(ref single_line_body_str)
+ Some(single_line_body_str)
if !single_line_body_str.contains('\n') =>
{
- Some(single_line_body_str.clone())
+ single_line_body_str
}
- _ => Some(body_str),
+ _ => body_str,
}
}
- _ => Some(body_str),
+ _ => body_str,
}
},
);
pub(crate) fn args_have_many_closure(args: &[OverflowableItem<'_>]) -> bool {
args.iter()
.filter_map(OverflowableItem::to_expr)
- .filter(|expr| match expr.kind {
- ast::ExprKind::Closure(..) => true,
- _ => false,
- })
+ .filter(|expr| matches!(expr.kind, ast::ExprKind::Closure(..)))
.count()
> 1
}