alertsleeper to Rust · 11 months agocmp::Ordering vs comparison symbolsmessage-squaremessage-square3fedilinkarrow-up114arrow-down10file-text
arrow-up114arrow-down1message-squarecmp::Ordering vs comparison symbolsalertsleeper to Rust · 11 months agomessage-square3fedilinkfile-text
beginner question: What is the advantage of using cmp::Ordering::Less over “<”, same for Greater and Equals?
minus-squaresugar_in_your_tea@sh.itjust.workslinkfedilinkarrow-up12·edit-211 months agoHere’s a good example. Basically, cmp::Ordering::Less is an enum so a match using it is guaranteed to be exhaustive, whereas you need to be careful when doing an if/else chain that you cover all cases.
Here’s a good example.
Basically,
cmp::Ordering::Less
is an enum so a match using it is guaranteed to be exhaustive, whereas you need to be careful when doing an if/else chain that you cover all cases.