You've already forked comprehensive-rust
							
							
				mirror of
				https://github.com/google/comprehensive-rust.git
				synced 2025-10-31 08:37:45 +02:00 
			
		
		
		
	Update match-guards.md
This commit is contained in:
		
				
					committed by
					
						 Andrew Walbran
						Andrew Walbran
					
				
			
			
				
	
			
			
			
						parent
						
							a0a1059c0d
						
					
				
				
					commit
					4588d95427
				
			| @@ -9,11 +9,10 @@ expression which will be executed if the pattern matches: | ||||
|  | ||||
| <details> | ||||
|  | ||||
| Match guards as a separate syntax feature are important and necessary. They are not | ||||
| the same as separate `if` expression inside of the match arm. | ||||
|    | ||||
| An `if` expression inside of the branch block (after `=>`) happens after the match arm | ||||
| is selected. Failing the `if` condition inside of that block won't result in other arms | ||||
| Key Points: | ||||
| * Match guards as a separate syntax feature are important and necessary. | ||||
| * They are not the same as separate `if` expression inside of the match arm. An `if` expression inside of the branch block (after `=>`) happens after the match arm is selected. Failing the `if` condition inside of that block won't result in other arms | ||||
| of the original `match` expression being considered.   | ||||
|    | ||||
| * You can use the variables defined in the pattern in your if expression. | ||||
| * The condition defined in the guard applies to every expression in a pattern with an `|`. | ||||
| </details> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user