monica_b1998@lemmy.world to Rust@programming.dev · 3 days agoError Handling in Rust vs. Exceptions in other languagesslicker.meexternal-linkmessage-square20fedilinkarrow-up134
arrow-up134external-linkError Handling in Rust vs. Exceptions in other languagesslicker.memonica_b1998@lemmy.world to Rust@programming.dev · 3 days agomessage-square20fedilink
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up2·2 days agoThat’s what ? is for. If you have to do that manually, something is not working correctly.
minus-squaretreadful@lemmy.zipcakelinkfedilinkEnglisharrow-up2·2 days agoThat only works if everything has the same error types.
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up4·2 days agoOr just implement Into for your error type. ? Works for Into
minus-squarejenesaisquoi@feddit.orglinkfedilinkEnglisharrow-up2·1 day 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