We have so many great functions to handle errors on a Result, but we have nothing to simply eprintln! it and go our merry way. Sometimes it's nice to always print the error (if any) without actually handling it.
This is one such example using channels for events:
tx.try_send(event)
.inspect_err(|e| eprintln!("{e}"))
.ok();
Could be just:
tx.try_send(event)
.print_err()
.ok();
I know it's not a huge deal, but the repetition of using the same exact format string every time got to me :)
We have so many great functions to handle errors on a Result, but we have nothing to simply
eprintln!it and go our merry way. Sometimes it's nice to always print the error (if any) without actually handling it.This is one such example using channels for events:
Could be just:
I know it's not a huge deal, but the repetition of using the same exact format string every time got to me :)