}
// FIXME(#2743)
ast::ExprKind::ObsoleteInPlace(..) => unimplemented!(),
- // FIXME(topecongiro) Format async block.
- ast::ExprKind::Async(..) => None,
+ ast::ExprKind::Async(capture_by, _node_id, ref block) => {
+ let mover = if capture_by == ast::CaptureBy::Value {
+ "move "
+ } else {
+ ""
+ };
+ if let rw @ Some(_) = rewrite_single_line_block(
+ context,
+ format!("{}{}", "async ", mover).as_str(),
+ block,
+ Some(&expr.attrs),
+ None,
+ shape,
+ ) {
+ rw
+ } else {
+ // 6 = `async `
+ let budget = shape.width.saturating_sub(6);
+ Some(format!(
+ "{}{}{}",
+ "async ",
+ mover,
+ rewrite_block(
+ block,
+ Some(&expr.attrs),
+ None,
+ context,
+ Shape::legacy(budget, shape.indent)
+ )?
+ ))
+ }
+ }
};
expr_rw
shape.width,
)
};
- let fmt = ListFormatting {
- tactic,
- separator: " |",
- trailing_separator: SeparatorTactic::Never,
- separator_place: context.config.binop_separator(),
- shape,
- ends_with_newline: false,
- preserve_newline: false,
- nested: false,
- config: context.config,
- };
+ let fmt = ListFormatting::new(shape, context.config)
+ .tactic(tactic)
+ .separator(" |")
+ .separator_place(context.config.binop_separator())
+ .ends_with_newline(false);
write_list(&items, &fmt)
}
Separator::Comma,
nested_shape.width,
);
- let fmt = ListFormatting {
- tactic,
- separator: ",",
- trailing_separator: SeparatorTactic::Never,
- separator_place: SeparatorPlace::Back,
- shape,
- ends_with_newline: false,
- preserve_newline: false,
- nested: false,
- config: context.config,
- };
+ let fmt = ListFormatting::new(shape, context.config)
+ .tactic(tactic)
+ .ends_with_newline(false);
let list_str = write_list(&item_vec, &fmt)?;
Some(format!("({})", list_str))