From 1994ffee27b1965ac998e1c9bee766edcf3c9567 Mon Sep 17 00:00:00 2001 From: edef Date: Tue, 30 Aug 2016 18:17:52 -0400 Subject: [PATCH] don't drop yielded values in the generator fix #31 --- src/generator.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/generator.rs b/src/generator.rs index 8ad9923..913ae78 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -199,6 +199,7 @@ impl Yielder unsafe { let data = Context::swap(self.context, self.context, &mut val as *mut Option as usize); + mem::forget(val); let (new_context, input) = ptr::read(data as *mut (*mut Context, Input)); // The generator can be moved (and with it, the context). // This changes the address of the context.