From b515ace90654fe038005c9b4449fc953c7f612b0 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 14 Apr 2023 01:21:58 +0200 Subject: [PATCH] Add InfallibleExt util trait --- src/main.rs | 1 + src/util.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/util.rs diff --git a/src/main.rs b/src/main.rs index 945ba7b..116c75a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,7 @@ mod logger; mod macros; mod store; mod ui; +mod util; mod vault; use std::path::PathBuf; diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..b6e7c97 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,15 @@ +use std::convert::Infallible; + +pub trait InfallibleExt { + type Inner; + + fn infallible(self) -> Self::Inner; +} + +impl InfallibleExt for Result { + type Inner = T; + + fn infallible(self) -> T { + self.expect("infallible") + } +}