summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2022-10-23 12:57:03 -0400
committerBotahamec <botahamec@outlook.com>2022-10-23 12:57:03 -0400
commit6fae1af77dbfc80b986427ad5a06d96565702c38 (patch)
tree9c22b59255cd701c3f9f853afb06403e1ad9595b /src
parentf52dc60a3c83d43be2b9df0e4a6e4fa0d704a7b3 (diff)
Rename UnexpectedError
Diffstat (limited to 'src')
-rw-r--r--src/exun.rs12
-rw-r--r--src/lib.rs2
-rw-r--r--src/result.rs18
-rw-r--r--src/unexpected.rs18
4 files changed, 25 insertions, 25 deletions
diff --git a/src/exun.rs b/src/exun.rs
index b870471..5f6bb43 100644
--- a/src/exun.rs
+++ b/src/exun.rs
@@ -4,19 +4,19 @@ use core::fmt::{self, Debug, Display};
use std::error::Error;
#[cfg(feature = "alloc")]
-use crate::UnexpectedError;
+use crate::RawUnexpected;
pub use Exun::{Expected, Unexpected};
/// `Expect` is a type that represents either the expected error type
-/// ([`Expected`]) or an unexpected error ([`Unexpected`]).
+/// ([`Expected`]) or an unexpected type ([`Unexpected`]).
///
/// See the [crate documentation](self) for details.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Exun<E, U> {
- /// Contains the expected error type
+ /// Contains the expected type
Expected(E),
- /// Contains an unexpected error
+ /// Contains an unexpected type
Unexpected(U),
}
@@ -47,8 +47,8 @@ impl<E: Error, U> From<E> for Exun<E, U> {
}
#[cfg(feature = "alloc")]
-impl<E> From<UnexpectedError> for Exun<E, UnexpectedError> {
- fn from(ue: UnexpectedError) -> Self {
+impl<E> From<RawUnexpected> for Exun<E, RawUnexpected> {
+ fn from(ue: RawUnexpected) -> Self {
Unexpected(ue)
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 70555a0..d078051 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -18,4 +18,4 @@ pub use result::ResultErrorExt;
#[cfg(feature = "alloc")]
pub use result::ResultMsgExt;
#[cfg(feature = "alloc")]
-pub use unexpected::UnexpectedError;
+pub use unexpected::RawUnexpected;
diff --git a/src/result.rs b/src/result.rs
index 03483d2..9f1bb89 100644
--- a/src/result.rs
+++ b/src/result.rs
@@ -1,7 +1,7 @@
#[cfg(feature = "std")]
use std::error::Error;
-use crate::{unexpected::Errorable, UnexpectedError};
+use crate::{unexpected::Errorable, RawUnexpected};
mod sealed {
pub trait Sealed {}
@@ -12,29 +12,29 @@ use sealed::Sealed;
#[cfg(feature = "std")]
pub trait ResultErrorExt<T>: Sealed {
- /// Converts `Result<T, E>` to `Result<T, UnexpectedError>`.
+ /// Converts `Result<T, E>` to `Result<T, RawUnexpected>`.
#[allow(clippy::missing_errors_doc)]
- fn unexpect(self) -> Result<T, UnexpectedError>;
+ fn unexpect(self) -> Result<T, RawUnexpected>;
}
#[cfg(feature = "std")]
impl<T, E: Error + Send + Sync + 'static> ResultErrorExt<T> for Result<T, E> {
- fn unexpect(self) -> Result<T, UnexpectedError> {
- self.map_err(UnexpectedError::new)
+ fn unexpect(self) -> Result<T, RawUnexpected> {
+ self.map_err(RawUnexpected::new)
}
}
pub trait ResultMsgExt<T>: Sealed {
- /// Converts `Result<T, E>` to `Result<T, UnexpectedError>`.
+ /// Converts `Result<T, E>` to `Result<T, RawUnExpected>`.
///
/// 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>;
+ fn unexpect_msg(self) -> Result<T, RawUnexpected>;
}
impl<T, E: Errorable + 'static> ResultMsgExt<T> for Result<T, E> {
- fn unexpect_msg(self) -> Result<T, UnexpectedError> {
- self.map_err(UnexpectedError::msg)
+ fn unexpect_msg(self) -> Result<T, RawUnexpected> {
+ self.map_err(RawUnexpected::msg)
}
}
diff --git a/src/unexpected.rs b/src/unexpected.rs
index 9355697..4b8f063 100644
--- a/src/unexpected.rs
+++ b/src/unexpected.rs
@@ -17,11 +17,11 @@ enum ErrorTy {
}
#[derive(Debug)]
-pub struct UnexpectedError {
+pub struct RawUnexpected {
internal: ErrorTy,
}
-impl Display for UnexpectedError {
+impl Display for RawUnexpected {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.internal {
ErrorTy::Message(m) => Display::fmt(&m, f),
@@ -32,17 +32,17 @@ impl Display for UnexpectedError {
}
#[cfg(feature = "std")]
-impl<T: Error + Send + Sync + 'static> From<T> for UnexpectedError {
+impl<T: Error + Send + Sync + 'static> From<T> for RawUnexpected {
fn from(e: T) -> Self {
Self::new(e)
}
}
-impl UnexpectedError {
- /// Create a new `UnexpectedError` from any [`Error`] type.
+impl RawUnexpected {
+ /// Create a new `RawUnexpected` from any [`Error`] type.
///
/// The error must be thread-safe and `'static` so that the
- /// `UnexpectedError` will be too.
+ /// `RawUnexpected` will be too.
///
/// # Examples
///
@@ -51,7 +51,7 @@ impl UnexpectedError {
/// ```
/// use exun::*;
///
- /// let err = UnexpectedError::new(core::fmt::Error);
+ /// let err = RawUnexpected::new(core::fmt::Error);
/// ```
#[cfg(feature = "std")]
pub fn new<E: Error + Send + Sync + 'static>(e: E) -> Self {
@@ -60,9 +60,9 @@ impl UnexpectedError {
}
}
- /// Create an error message from a printable error message.
+ /// Create a new `RawUnexpected` from a printable error message.
///
- /// If the argument implements [`Error`], prefer [`UnexpectedError::new`]
+ /// If the argument implements [`Error`], prefer [`RawUnexpected::new`]
/// instead, which preserves the source.
///
/// # Examples