From c089a353ae1c30edfeb794b7b3bdd0d225766865 Mon Sep 17 00:00:00 2001 From: Botahamec Date: Sun, 23 Oct 2022 12:49:40 -0400 Subject: Export Result extensions --- src/lib.rs | 4 ++++ src/result.rs | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 20d9580..70555a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,5 +13,9 @@ mod result; mod unexpected; pub use exun::*; +#[cfg(feature = "std")] +pub use result::ResultErrorExt; +#[cfg(feature = "alloc")] +pub use result::ResultMsgExt; #[cfg(feature = "alloc")] pub use unexpected::UnexpectedError; diff --git a/src/result.rs b/src/result.rs index d5de01b..94ebab2 100644 --- a/src/result.rs +++ b/src/result.rs @@ -4,7 +4,9 @@ use std::error::Error; use crate::{unexpected::Errorable, UnexpectedError}; #[cfg(feature = "std")] -trait ResultErrorExt { +pub trait ResultErrorExt { + /// Converts `Result` to `Result`. + #[allow(clippy::missing_errors_doc)] fn unexpect(self) -> Result; } @@ -15,7 +17,12 @@ impl ResultErrorExt for Result { } } -trait ResultMsgExt { +pub trait ResultMsgExt { + /// Converts `Result` to `Result`. + /// + /// This is provided for compatibility with `no_std`. If your type + /// implements [`Error`], then you should prefer that instead. + #[allow(clippy::missing_errors_doc)] fn unexpect_msg(self) -> Result; } -- cgit v1.2.3