Mastodon Feed: Post

Mastodon Feed

NfNitLoop ("Cody Casterline πŸ³οΈβ€πŸŒˆ") wrote:

@jsonstein expect() and panic!() do have their place.

When prototyping, it's fine to .expect() or .unwrap() for error cases you don't care to handle right now.

For "production" code, you should only .expect()/panic!() for cases that you've proven can't happen (or are so rare you don't want to handle.)

Otherwise, you can use Rust's `?` error propagation and something like the Anyhow crate (https://github.com/dtolnay/anyhow) for much less boilerplate-y error handling that doesn't crash your program. 😊