• BB_C@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    4 months ago

    Now that I think about it, I don’t like how unwrap can signal either “I know this can’t fail”, “the possible error states are too rare to care about” or “I can’t be bothered with real error handing right now”.

    That’s why you’re told (clippy does that i think) to use expect instead, so you can signal “whatever string” you want to signal precisely.

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      Exactly! My code has a handful of “expect()” calls in it, and each one self-documents why it’s okay. It’s like a comment, but it appears in logs if it ever triggers.