diff options
| author | Botahamec <botahamec@outlook.com> | 2022-10-23 09:52:19 -0400 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2022-10-23 09:52:19 -0400 |
| commit | 4147aa5450383d1dba9bc3739d56408fed8b0b58 (patch) | |
| tree | 9845ee99cd9464fb6f5606dfbf36fe63b598cef2 /src/exun.rs | |
| parent | adcaae8643333e26d1f9b3c67ae7451e65e7446b (diff) | |
Implement From<UnexpectedError>
Diffstat (limited to 'src/exun.rs')
| -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>`]. /// |
