Skip to content

Commit 6267818

Browse files
committed
TranslateErr: add helper function to unwrap impossible case
1 parent e1f0802 commit 6267818

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,20 @@ impl<E> TranslateErr<E> {
365365
}
366366
}
367367

368+
impl TranslateErr<core::convert::Infallible> {
369+
/// Remove the impossible "translator error" case and return a context error.
370+
///
371+
/// When the translator error type is [`core::convert::Infallible`], which is
372+
/// impossible to construct, allows unwrapping the outer error without any
373+
/// panic paths.
374+
pub fn into_outer_err(self) -> Error {
375+
match self {
376+
Self::TranslatorErr(impossible) => match impossible {},
377+
Self::OuterError(e) => e,
378+
}
379+
}
380+
}
381+
368382
impl TranslateErr<Error> {
369383
/// If we are doing a translation where our "outer error" is the generic
370384
/// Miniscript error, eliminate the `TranslateErr` type which is just noise.

0 commit comments

Comments
 (0)