logoalt Hacker News

watttoday at 8:39 AM1 replyview on HN

If 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.


Replies

a_cultoday at 9:24 AM

You'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
  }
  ...
show 1 reply