Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #![feature(
  2. async_await,
  3. async_closure,
  4. )]
  5.  
  6. use core::future::Future;
  7.  
  8. async fn closure_caller<F>(f: Box<F>) -> Result<usize, ()>
  9. where F: FnOnce(i64) -> dyn Future<Output = Result<usize, ()>>,
  10. {
  11. f(7).await
  12. }
  13.  
  14. fn main() {
  15. closure_caller(
  16. Box::new(async move |n| {
  17. Ok(n + 5)
  18. })
  19. );
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement