Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(
- async_await,
- async_closure,
- )]
- use core::future::Future;
- async fn closure_caller<F>(f: Box<F>) -> Result<usize, ()>
- where F: FnOnce(i64) -> dyn Future<Output = Result<usize, ()>>,
- {
- f(7).await
- }
- fn main() {
- closure_caller(
- Box::new(async move |n| {
- Ok(n + 5)
- })
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement