extern crate context;
use context::{Context, Transfer};
use context::stack::ProtectedFixedSizeStack;
fn main() {
extern "C" fn context_function(mut t: Transfer) -> ! {
for i in 0usize.. {
print!("Yielding {} => ", i);
t = unsafe { t.context.resume(i) };
}
unreachable!();
}
let stack = ProtectedFixedSizeStack::default();
let mut t = Transfer::new(unsafe { Context::new(&stack, context_function) }, 0);
for _ in 0..10 {
print!("Resuming => ");
t = unsafe { t.context.resume(0) };
println!("Got {}", t.data);
}
println!("Finished!");
}