StreamExt::scan: specified lifetime requirements#2046
StreamExt::scan: specified lifetime requirements#2046olegnn wants to merge 8 commits intorust-lang:masterfrom
StreamExt::scan: specified lifetime requirements#2046Conversation
|
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
scanrealisation doesn't allow to capture&mutstate in future. This PR adds adds lifetime requirements and allows to use&mutstate in async functions and blocks. @cramertj is this solution ok?