You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
471 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## 函数的入参是一个async function
因为我们使用了trait bound所以不能用`Fn() -> impl Future<Output=Result<Return, sql::Error>>`的方式.
```rust
use core::future::Future;
pub async fn on_tran<F, Fut>(f: F) -> usize
where F: Fn() -> Fut, Fut: Future<Output=usize> {
f().await
}
#[tokio::main]
async fn main() {
let foo = || {
async {
8 as usize
}
};
println!("{}", on_tran(foo).await);
}
```