-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Temporary values do not outlive a direct await #63778
Comments
Going with a moving API over For redis, where I encountered this it is possible to avoid capturing Changing it would at least change the drop order for temporaries so this might be a stability hazard (maybe not since it doesn't compile?). |
This seems like the same issue as #63832? |
Closing as a duplicate of #63832, I'll move the example over there though to be sure. |
https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=2649e4f172c54090d759b2f9484b31e1
A fairly common pattern is to use builder functions that takes
&mut self
and returns&mut Self
so that multiple builder methods can be used in a row followed by building/using the final value. With normal, sync functions this works fine since the created temporary lives as long as the enclosing statement but if the final result isawait
ed on then we instead get an error.This forces such builders to use moving functions
fn (self) -> Self
which can limit their use or to always write the builder asIs it possible and/or planned that temporaries can be used in this way with await?
The text was updated successfully, but these errors were encountered: