Hello,
In the code below, the pick3
function doesn't compile. I'm wondering if I'm missing something or if this is a limitation of the current compiler.
#![feature(type_alias_impl_trait)]
#![feature(async_closure)]
#![allow(dead_code, unused_imports)]
use std::fmt::Display;
use std::future::Future;
async fn pick1<T, I: Iterator<Item = T>>(input: &mut I) -> T {
input.next().unwrap()
}
async fn pick2<T, I: Iterator<Item = T>>(input: &mut I) -> T {
type __ReturnType<T> = T;
let body = (async move || -> __ReturnType<T> { input.next().unwrap() })();
return tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed building the runtime")
.block_on(body);
}
async fn pick3<'a, T, I: Iterator<Item = T>>(input: &'a mut I) -> T {
type __FutureType<'a, T> = impl Future<Output = T> + 'a;
let body: __FutureType<'a, T> = async move { input.next().unwrap() };
return tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed building the runtime")
.block_on(body);
}
error: type parameter `I` is part of concrete type but not used in parameter list for the `impl Trait` type alias
--> src\lib.rs:27:37
|
27 | let body: __FutureType<'a, T> = async move { input.next().unwrap() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^