3 ms·
It is an explicit way to discard return values; `self.poll_read(cx)?` etc. alone would warn. Or in this case, `Poll<Result<(), Error>>` is unwrapped once and `R
by lifthrasiir 4mo ago
It is an explicit way to discard return values; `self.poll_read(cx)?` etc. alone would warn. Or in this case, `Poll<Result<(), Error>>` is unwrapped once and `Result<(), Error>` is being discarded. The decision to discard `Result<(), Error>` should have been intentional, albeit turned out to be not always the case.
- watt 4mo agoIf they're not going to handle the return values, they should change the function signature to reflect this aspirational contract, that that function "never fails". I see in the article they did change the poll_flush to run just-in-time at poll_shutdown. So they definitely can make a "best effort" poll_flush version that just does not return any errors for use in that loop. But all in all? Amateur hour.
- a_cul 4mo agoYou're missing how rust works. The function is explicitly allowed to fail, which is why it returns a Result<(), Error>. They're using the function calls within for their side effects. The ? at the end of each line signals that the function will short-circuit return with an error if the function call fails, and only if it is successful it returns the actual value: they just don't care about this value, hence the let _ =. Basically, they are doing the equivalent of: let _, err = function_call(); if err { return err } ...
- watt 4mo agoWhat I am saying, is make another version of the function, which is explicitly not allowed to fail, if you want to use it in the loop.
- deleted 4mo ago[deleted]