use core::prelude::*; use arch::Registers; use stack; pub struct Context { regs: Registers, stack: Stack } impl Context where Stack: stack::Stack { #[inline] pub unsafe fn new(mut stack: Stack, f: F) -> Context where F: FnOnce() + Send + 'static { let regs = Registers::new(&mut stack, f); Context { regs: regs, stack: stack } } #[inline(always)] pub unsafe fn swap(&mut self) { self.regs.swap() } pub unsafe fn destroy(self) -> Stack { self.stack } }