use syntax::source_map::{BytePos, Span};
use syntax::{ast, ptr};
-use source_map::SpanUtils;
use comment::{combine_strs_with_missing_comments, rewrite_comment};
use config::{Config, ControlBraceStyle, IndentStyle};
use expr::{
use lists::{itemize_list, write_list, ListFormatting};
use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
+use source_map::SpanUtils;
use spanned::Spanned;
use utils::{
contains_skip, extra_offset, first_line_width, inner_attributes, last_line_extendable, mk_sp,
fn rewrite_match_pattern(
context: &RewriteContext,
pats: &[&ast::Pat],
- guard: &Option<ptr::P<ast::Expr>>,
+ guard: &Option<ast::Guard>,
shape: Shape,
) -> Option<String> {
// Patterns
guard,
shape,
trimmed_last_line_width(&pats_str),
- pats_str.contains("\n"),
+ pats_str.contains('\n'),
)?;
Some(format!("{}{}", pats_str, guard_str))
}
}
+impl Rewrite for ast::Guard {
+ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+ match self {
+ ast::Guard::If(ref expr) => expr.rewrite(context, shape),
+ }
+ }
+}
+
// The `if ...` guard on a match arm.
fn rewrite_guard(
context: &RewriteContext,
- guard: &Option<ptr::P<ast::Expr>>,
+ guard: &Option<ast::Guard>,
shape: Shape,
// The amount of space used up on this line for the pattern in
// the arm (excludes offset).