File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -339,9 +339,9 @@ impl Rewrite for Pat {
339339 . max_width_error ( shape. width , self . span ) ?,
340340 )
341341 . map ( |inner_pat| format ! ( "({})" , inner_pat) ) ,
342- PatKind :: Err ( _ ) => Err ( RewriteError :: Unknown ) ,
342+ PatKind :: Guard ( .. ) => Ok ( context . snippet ( self . span ) . to_string ( ) ) ,
343343 PatKind :: Deref ( _) => Err ( RewriteError :: Unknown ) ,
344- PatKind :: Guard ( .. ) => Err ( RewriteError :: Unknown ) ,
344+ PatKind :: Err ( _ ) => Err ( RewriteError :: Unknown ) ,
345345 }
346346 }
347347}
Original file line number Diff line number Diff line change 1+ #![ feature( guard_patterns) ]
2+
3+ fn main ( ) {
4+ match user. subscription_plan ( ) {
5+ ( Plan :: Regular if user. credit ( ) >= 100 ) | ( Plan :: Premium if user. credit ( ) >= 80 ) => {
6+ // Complete the transaction.
7+ }
8+ _ => {
9+ // The user doesn't have enough credit, return an error message.
10+ }
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments