Created
July 28, 2019 14:10
-
-
Save yoshuawuyts/846b929c7938fd545bcbacbdfbdd4c55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait AsyncRead { | |
async fn read(&self, buf: &mut [u8]) -> io::Result<usize>; | |
} | |
fn main () { | |
let mut buf = vec![0; 1024]; | |
let bytes_read = read(&mut buf).await?; | |
dbg!(buf); | |
} | |
//// | |
trait AsyncRead { | |
fn read(&self, buf: Vec<u8>) -> Future<Output = (io::Result<usize>>, Vec<u8>); | |
} | |
fn main () { | |
let mut buf = vec![0; 1024]; | |
let (bytes_read, buf) = read(buf).await?; | |
dbg!(buf); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment