mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			309 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			309 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //@ run-pass
 | |
| // Check that closures implement `Copy`.
 | |
| 
 | |
| fn call<T, F: FnOnce() -> T>(f: F) -> T { f() }
 | |
| 
 | |
| fn main() {
 | |
|     let a = 5;
 | |
|     let hello = || {
 | |
|         println!("Hello {}", a);
 | |
|         a
 | |
|     };
 | |
| 
 | |
|     assert_eq!(5, call(hello.clone()));
 | |
|     assert_eq!(5, call(hello));
 | |
|     assert_eq!(5, call(hello));
 | |
| }
 | 
