mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			412 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			412 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| // run-pass
 | |
| 
 | |
| #![feature(coroutines, coroutine_trait)]
 | |
| 
 | |
| use std::ops::{Coroutine, CoroutineState};
 | |
| use std::pin::Pin;
 | |
| 
 | |
| fn main() {
 | |
|     let _coroutine = || {
 | |
|         let mut sub_coroutine = || {
 | |
|             yield 2;
 | |
|         };
 | |
| 
 | |
|         match Pin::new(&mut sub_coroutine).resume(()) {
 | |
|             CoroutineState::Yielded(x) => {
 | |
|                 yield x;
 | |
|             }
 | |
|             _ => panic!(),
 | |
|         };
 | |
|     };
 | |
| }
 | 
