monica_b1998@lemmy.world to Rust@programming.dev · 9 days agoError Handling in Rust vs. Exceptions in other languagesslicker.meexternal-linkmessage-square22fedilinkarrow-up134arrow-down11
arrow-up133arrow-down1external-linkError Handling in Rust vs. Exceptions in other languagesslicker.memonica_b1998@lemmy.world to Rust@programming.dev · 9 days agomessage-square22fedilink
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up2arrow-down3·8 days agoThat’s what ? is for. If you have to do that manually, something is not working correctly.
minus-squaretreadful@lemmy.ziplinkfedilinkEnglisharrow-up2arrow-down1·8 days agoThat only works if everything has the same error types.
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up4·8 days agoOr just implement Into for your error type. ? Works for Into
minus-squarejenesaisquoi@feddit.orglinkfedilinkEnglisharrow-up2·7 days agoDon’t implement Into, instead, implement From - and you’ll get Into for free
That’s what
?is for. If you have to do that manually, something is not working correctly.That only works if everything has the same error types.
Or just implement Into for your error type. ? Works for Into
Don’t implement
Into, instead, implementFrom- and you’ll getIntofor free