don't drop yielded values in the generator

fix #31
This commit is contained in:
edef 2016-08-30 18:17:52 -04:00
parent 89a8f68c7e
commit 1994ffee27
1 changed files with 1 additions and 0 deletions

View File

@ -199,6 +199,7 @@ impl<Input, Output, Stack> Yielder<Input, Output, Stack>
unsafe {
let data = Context::swap(self.context, self.context,
&mut val as *mut Option<Output> as usize);
mem::forget(val);
let (new_context, input) = ptr::read(data as *mut (*mut Context<Stack>, Input));
// The generator can be moved (and with it, the context).
// This changes the address of the context.