1
0
Fork 0

Require Stack to be 'static

Our strategy of leaking the Stack to ensure safety is only effective if
the lifetime of the underlying stack memory is controlled by the
destructor of the Stack. We don't add this bound to unsafe_new, so that
users who wish to provide the necessary guarantees themselves can do so.
This commit is contained in:
edef 2017-03-05 21:58:01 +01:00
parent 277e786d3f
commit d49557a55a
1 changed files with 1 additions and 1 deletions

View File

@ -111,7 +111,7 @@ impl<'a, Input, Output, Stack> Generator<'a, Input, Output, Stack>
/// ///
/// See also the [contract](../trait.GuardedStack.html) that needs to be fulfilled by `stack`. /// See also the [contract](../trait.GuardedStack.html) that needs to be fulfilled by `stack`.
pub fn new<F>(stack: Stack, f: F) -> Generator<'a, Input, Output, Stack> pub fn new<F>(stack: Stack, f: F) -> Generator<'a, Input, Output, Stack>
where Stack: stack::GuardedStack, where Stack: stack::GuardedStack + 'static,
F: FnOnce(&Yielder<Input, Output>, Input) + 'a { F: FnOnce(&Yielder<Input, Output>, Input) + 'a {
unsafe { Generator::unsafe_new(stack, f) } unsafe { Generator::unsafe_new(stack, f) }
} }