Skip to content

Instantly share code, notes, and snippets.

@jeromegn
Created November 19, 2025 14:16
Show Gist options
  • Select an option

  • Save jeromegn/9f053088ed6a1193a4271b91e14fd979 to your computer and use it in GitHub Desktop.

Select an option

Save jeromegn/9f053088ed6a1193a4271b91e14fd979 to your computer and use it in GitHub Desktop.
#![deny(clippy::unwrap_used)]
fn main() {
Err::<(), _>("foo").or_panic()
}
trait UnwrapPanic<T> {
fn or_panic(self) -> T;
}
impl<T, E> UnwrapPanic<T> for Result<T, E> where E: std::fmt::Debug {
fn or_panic(self) -> T {
#[allow(clippy::unwrap_used)]
self.unwrap()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment