beginner question: What is the advantage of using cmp::Ordering::Less over “<”, same for Greater and Equals?

  • sugar_in_your_tea
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    9 months ago

    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.