diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/exun.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/exun.rs b/src/exun.rs index 8a20be6..b870471 100644 --- a/src/exun.rs +++ b/src/exun.rs @@ -3,6 +3,9 @@ use core::fmt::{self, Debug, Display}; #[cfg(feature = "std")] use std::error::Error; +#[cfg(feature = "alloc")] +use crate::UnexpectedError; + pub use Exun::{Expected, Unexpected}; /// `Expect` is a type that represents either the expected error type @@ -36,12 +39,20 @@ impl<E: Error + 'static, U: Error + 'static> Error for Exun<E, U> { } } -impl<E, U> From<E> for Exun<E, U> { +#[cfg(feature = "std")] +impl<E: Error, U> From<E> for Exun<E, U> { fn from(e: E) -> Self { Expected(e) } } +#[cfg(feature = "alloc")] +impl<E> From<UnexpectedError> for Exun<E, UnexpectedError> { + fn from(ue: UnexpectedError) -> Self { + Unexpected(ue) + } +} + impl<E, U> Exun<E, U> { /// Converts from `Expect<E, U>` to [`Option<E>`]. /// |
