error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == usize`
--> src/lib.rs:2:13
|
2 | vec![|| Box::new(async { 5 }) as Box<_>; width]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected usize, found i32
|
= note: required for the cast to the object type `dyn std::future::Future<Output = usize>`
error[E0271]: type mismatch resolving `<[closure@src/lib.rs:2:10: 2:39] as std::ops::FnOnce<()>>::Output == std::boxed::Box<(dyn std::future::Future<Output = usize> + 'static)>`
--> src/lib.rs:1:41
|
1 | fn get_closure_vec(width: usize) -> Vec<impl Fn() -> Box<dyn std::future::Future<Output = usize>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found trait std::future::Future
|
= note: expected type `std::boxed::Box<impl std::future::Future>`
found type `std::boxed::Box<(dyn std::future::Future<Output = usize> + 'static)>`
= note: the return type of a function must have a statically known size
This code (Playground)
gives error
and this code (Playground)
also gives error
while this one works fine (Playground)