summary refs log tree commit diff
path: root/rust/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/lib.rs')
-rw-r--r--rust/src/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs

index 5de9238326..d751889874 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs
@@ -1,3 +1,5 @@ +use std::convert::Infallible; + use lazy_static::lazy_static; use pyo3::prelude::*; use pyo3_log::ResetHandle; @@ -52,3 +54,16 @@ fn synapse_rust(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { Ok(()) } + +pub trait UnwrapInfallible<T> { + fn unwrap_infallible(self) -> T; +} + +impl<T> UnwrapInfallible<T> for Result<T, Infallible> { + fn unwrap_infallible(self) -> T { + match self { + Ok(val) => val, + Err(never) => match never {}, + } + } +}