monica_b1998@lemmy.world to Rust@programming.dev · 2 months agoError Handling in Rust vs. Exceptions in other languagesslicker.meexternal-linkmessage-square24linkfedilinkarrow-up136arrow-down11
arrow-up135arrow-down1external-linkError Handling in Rust vs. Exceptions in other languagesslicker.memonica_b1998@lemmy.world to Rust@programming.dev · 2 months agomessage-square24linkfedilink
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up2arrow-down3·2 months agoThat’s what ? is for. If you have to do that manually, something is not working correctly.
minus-squaretreadful@lemmy.ziplinkfedilinkEnglisharrow-up2arrow-down2·2 months agoThat only works if everything has the same error types.
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up4·2 months agoOr just implement Into for your error type. ? Works for Into
minus-squarejenesaisquoi@feddit.orglinkfedilinkEnglisharrow-up2·2 months 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