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