Closed
Description
Code
// Full code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=03b0d135b9b888d739a99a580d406314
let g = async || 1;
let h = async || 1;
let f = {
let g_plus_h = memoize!(g().await + h().await);
let two_plus_two = memoize!(2 + 2);
async move || -> Vec<Shared<Pin<Box<dyn Future<Output = i64> + Send + 'static>>>> {
vec![g_plus_h, two_plus_two]
}
};
let a = f().await[0].await;
let b = f().await[1].await;
Current output
error[E0507]: cannot move out of index of `Vec<Shared<Pin<Box<dyn futures::Future<Output = i64> + std::marker::Send>>>>`
--> src/main.rs:62:13
|
62 | let a = f().await[0].await;
| ^^^^^^^^^^^^------ value moved due to this method call
| |
| move occurs because value has type `Shared<Pin<Box<dyn futures::Future<Output = i64> + std::marker::Send>>>`, which does not implement the `Copy` trait
|
note: `std::future::IntoFuture::into_future` takes ownership of the receiver `self`, which moves value
--> /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/core/src/future/into_future.rs:128:20
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
62 | let a = f().await[0]clone()..await;
| ++++++++
Desired output
Instead of `clone()..await` it should be `.clone().await`.
Rationale and extra context
Other cases
No response
Anything else?
No response