summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2022-10-23 12:49:40 -0400
committerBotahamec <botahamec@outlook.com>2022-10-23 12:49:40 -0400
commitc089a353ae1c30edfeb794b7b3bdd0d225766865 (patch)
tree360a681790ccb32999bde47c9a30c7b7753ab66a
parent7bc23b4865b39b9af900d7e2643ef1315793ba18 (diff)
Export Result extensions
-rw-r--r--src/lib.rs4
-rw-r--r--src/result.rs11
2 files changed, 13 insertions, 2 deletions
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<T> {
+pub trait ResultErrorExt<T> {
+ /// Converts `Result<T, E>` to `Result<T, UnexpectedError>`.
+ #[allow(clippy::missing_errors_doc)]
fn unexpect(self) -> Result<T, UnexpectedError>;
}
@@ -15,7 +17,12 @@ impl<T, E: Error + Send + Sync + 'static> ResultErrorExt<T> for Result<T, E> {
}
}
-trait ResultMsgExt<T> {
+pub trait ResultMsgExt<T> {
+ /// Converts `Result<T, E>` to `Result<T, UnexpectedError>`.
+ ///
+ /// 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<T, UnexpectedError>;
}