Skip to content

Commit 31d40e5

Browse files
committed
Add or-patterns to pattern types
1 parent 1abbb92 commit 31d40e5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/types.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,19 @@ impl Rewrite for ast::TyPat {
10931093
ast::TyPatKind::Range(ref lhs, ref rhs, ref end_kind) => {
10941094
rewrite_range_pat(context, shape, lhs, rhs, end_kind, self.span)
10951095
}
1096+
ast::TyPatKind::Or(ref variants) => {
1097+
let mut first = true;
1098+
let mut s = String::new();
1099+
for variant in variants {
1100+
if first {
1101+
first = false
1102+
} else {
1103+
s.push_str(" | ");
1104+
}
1105+
s.push_str(&variant.rewrite_result(context, shape)?);
1106+
}
1107+
Ok(s)
1108+
}
10961109
ast::TyPatKind::Err(_) => Err(RewriteError::Unknown),
10971110
}
10981111
}

0 commit comments

Comments
 (0)