ITADN

Add print_err to Result

#3900Openleaty 创建于 2025-12-29
L
leatycommented
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: ```rust tx.try_send(event) .inspect_err(|e| eprintln!("{e}")) .ok(); ``` Could be just: ```rust 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 :)
1 条评论