4 ms·
Because synchronous IO functions block the current thread and return the value directly, while asynchronous function return a `Future`, which will eventually re
by ibraheemdev 5y ago
Because synchronous IO functions block the current thread and return the value directly, while asynchronous function return a `Future`, which will eventually resolve to the value, and can be polled concurrently with other futures as to never block.
fn sync_read() -> Vec<u8> { ... }
fn async_read() -> impl Future<Output = Vec<u8>> { ... }
// the second can be written more succinctly as:
async fn async_read() -> Vec<u8> { ... }