mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			370 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			370 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //@ run-fail
 | |
| //@ error-pattern:Number is odd
 | |
| //@ needs-subprocess
 | |
| 
 | |
| fn even(x: usize) -> bool {
 | |
|     if x < 2 {
 | |
|         return false;
 | |
|     } else if x == 2 {
 | |
|         return true;
 | |
|     } else {
 | |
|         return even(x - 2);
 | |
|     }
 | |
| }
 | |
| 
 | |
| fn foo(x: usize) {
 | |
|     if even(x) {
 | |
|         println!("{}", x);
 | |
|     } else {
 | |
|         panic!("Number is odd");
 | |
|     }
 | |
| }
 | |
| 
 | |
| fn main() {
 | |
|     foo(3);
 | |
| }
 | 
