-
Notifications
You must be signed in to change notification settings - Fork 652
StreamExt::scan
: specified lifetime requirements
#2046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Unfortunately this is unsound-- it's giving the closure access to the mutable reference for the entire lifetime |
The real type of the closure you'd want is something like |
@cramertj but future returned by provided function is stored internally in |
I firstly tried higher rank trait bound of course, but it doesn’t work properly yet :( |
Way to “hack” which I see is to spawn a thread from function with mutable reference or assign it to static items/other long-lived variables in scope. But I need to check if it compiles. |
The reference it gets will have a
Yup, unfortunately there are a bunch of bugs around HRTB that make this not work yet. See #1023 for my own struggle to make this work. Maybe we can bug @nikomatsakis or someone else to take a look at fixing rust-lang/rust#51004 :) |
As mentioned in #2044 (comment), current
scan
realisation doesn't allow to capture&mut
state in future. This PR adds adds lifetime requirements and allows to use&mut
state in async functions and blocks. @cramertj is this solution ok?