具有一个静态引用的异步函数编译:
pub async fn test_0(_a: &'static str) {
}
Run Code Online (Sandbox Code Playgroud)
具有非静态和静态引用的异步函数编译:
pub async fn test_1<'a>(_a: &'a str, _b: &'static str) {
}
Run Code Online (Sandbox Code Playgroud)
具有三个非静态引用的异步函数编译:
pub async fn test_2<'a, 'b, 'c>(_a: &'a str, _b: &'b str, _c: &'c str) {
}
Run Code Online (Sandbox Code Playgroud)
接受两个非静态引用和一个静态引用并返回未来编译的函数:
pub fn test_3_desugared<'a, 'b>(_a: &'a str, _b: &'b str, _c: &'static str) -> impl std::future::Future<Output=()> {
std::future::ready(())
}
Run Code Online (Sandbox Code Playgroud)
那么为什么采用两个非静态引用和一个静态引用的异步函数无法编译呢?
pub async fn test_3<'a, 'b>(_a: &'a str, _b: &'b str, _c: &'static str) {
}
Run Code Online (Sandbox Code Playgroud)
有问题的编译错误:
error[E0700]: hidden type for …
Run Code Online (Sandbox Code Playgroud)