4 ms·
Can you "match" on the result to destructure it as well ? Without blocking the event loop ?
by fooyc 10y ago
Can you "match" on the result to destructure it as well ? Without blocking the event loop ?
- Manishearth 10y agoFutures aren't enums. I meant that you have the ability to handle it there and then (block on it via threadpool), or defer handling (chain to the next async calls in your async function). You have this same pair of abilities with Option, which bridges the basically nonexistant gap between fallible and infallible functions.
- fooyc 10y agoIsn't this adding a lot of overhead compared to calling a synchronous implementation of the same code ?
- Manishearth 10y agoYou'd have to block on I/O somehow. You can avoid the threadpool costs to block, too, IIRC (but that's worse)
- fooyc 10y agoThat's the point. Calling a blocking system call is cheaper that artificially blocking on a non-blocking operation.