| Crates.io | or-panic |
| lib.rs | or-panic |
| version | 1.0.2 |
| created_at | 2025-11-18 06:23:49.63969+00 |
| updated_at | 2025-11-20 03:26:09.80539+00 |
| description | unwrap or panic |
| homepage | |
| repository | https://github.com/antonio-hickey/or-panic |
| max_upload_size | |
| id | 1937947 |
| size | 21,120 |
A tiny extension trait that adds idiomatic .or_panic(..) methods to Option and Result.
[dependencies]
or-panic = "1.0.0"
use or_panic::ResultOrPanic;
fn main() {
let duration = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.or_panic("oh no, the chrono demons have reversed the fabric of time");
let secs = duration.as_secs();
println!("Seconds since epoch: {secs}");
}
DisplayResultno_std support
default-features = false
features = ["no_std"]
Add the crate to your Cargo.toml:
[dependencies]
or-panic = "1.0.0"
Import the traits:
use or_panic::prelude::*;
Use it:
let host = std::env::var("HOST")
.or_panic("HOST environment variable must be set");
or-panic supports no_std environments.
Enable no_std mode like so:
[dependencies]
or-panic = { version = "1.0.0", default-features = false, features = ["no_std"] }