Don’t say anyway, say anyhow

    • magic_lobster_party@fedia.io
      link
      fedilink
      arrow-up
      24
      ·
      11 days ago

      Unwrap means it forces to evaluate the result as an ”ok value”. If it’s an ”error value”, it will crash. It’s a bad practice to rely on it, as it’s one of the most common ways a Rust programs can crash.

      Rust offers many options to handle errors that don’t risk crashing. For example, unwrap_or_default, which means ”if it’s an error value, use the default value for this type, such as 0 for integers”