or-panic 🫨🤯
A tiny extension trait that adds idiomatic .or_panic(..) methods to Option and Result.
[]
= "1.0.0"
Example
use ResultOrPanic;
Features
- Ergonomic unwrapping
- Works with any
Display - Pretty panic messages with
Result - Context on the exact line of panic
- Optional
no_stdsupport- enabled via:
default-features = false features = ["no_std"]
- enabled via:
Quick Start
Add the crate to your Cargo.toml:
[]
= "1.0.0"
Import the traits:
use *;
Use it:
let host = std::env::var("HOST")
.or_panic("HOST environment variable must be set");
no_std support
or-panic supports no_std environments.
Enable no_std mode like so:
[]
= { = "1.0.0", = false, = ["no_std"] }