You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems as though it's not possible currently to write a generator that satisfies this bound:
fn accept<G: for<'a> Generator<&'a ()>>(g: G) {}
Trying something like this:
accept(|r| {
let r = yield;
});
Gives:
5 | fn accept<G>(g: G)
| ------
6 | where
7 | G: for<'a> Generator<&'a ()>,
| ------------------------- required by this bound in `accept`
...
12 | accept(|r| {
| ^^^^^^
| |
| expected signature of `for<'a> fn(&'a ()) -> _`
| found signature of `fn(_) -> _`
I realize that generators are very unstable right now so I doubt this is high priority, but hopefully something like this could work eventually? I think it might be useful for generators to accept something like a temporary buffer as a resume argument that should only be valid until the next call to yield.
Incidentally, I didn't run into this problem legitimately, I ran into it trying to abuse generators to enable automatic garbage collection ala https://github.com/kyren/gc-arena, but I think that there are also valid reasons to want this to work as well 😛
The text was updated successfully, but these errors were encountered:
It seems as though it's not possible currently to write a generator that satisfies this bound:
Trying something like this:
Gives:
I realize that generators are very unstable right now so I doubt this is high priority, but hopefully something like this could work eventually? I think it might be useful for generators to accept something like a temporary buffer as a resume argument that should only be valid until the next call to yield.
Incidentally, I didn't run into this problem legitimately, I ran into it trying to abuse generators to enable automatic garbage collection ala https://github.com/kyren/gc-arena, but I think that there are also valid reasons to want this to work as well 😛
The text was updated successfully, but these errors were encountered: