Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #![feature(async_await)]
  2. use core::future::Future;
  3.  
  4. fn main() {
  5. new_session_wrapper(dispatch);
  6. }
  7.  
  8. pub async fn dispatch(buf: &mut [u8]) -> Result<(), ()> {
  9. buf[0] = 1;
  10. Ok(())
  11. }
  12.  
  13. pub async fn new_session_wrapper<RET, DISPATCH>(mut dispatch: DISPATCH) -> ()
  14. where
  15. DISPATCH: for<'a> FnMut(&'a mut [u8]) -> RET,
  16. RET: Future<Output = Result<(), ()>> + Send,
  17. {
  18. let mut buf = [0; 10];
  19. loop {
  20. dispatch(&mut buf[..]).await;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement