Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(async_await)]
- use core::future::Future;
- fn main() {
- new_session_wrapper(dispatch);
- }
- pub async fn dispatch(buf: &mut [u8]) -> Result<(), ()> {
- buf[0] = 1;
- Ok(())
- }
- pub async fn new_session_wrapper<RET, DISPATCH>(mut dispatch: DISPATCH) -> ()
- where
- DISPATCH: for<'a> FnMut(&'a mut [u8]) -> RET,
- RET: Future<Output = Result<(), ()>> + Send,
- {
- let mut buf = [0; 10];
- loop {
- dispatch(&mut buf[..]).await;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement