36 lines
611 B
Rust
36 lines
611 B
Rust
use crate::How;
|
|
|
|
mod private {
|
|
use crate::How;
|
|
|
|
#[doc(hidden)]
|
|
pub trait IntoResultHow: Sized {
|
|
type T;
|
|
|
|
fn into_result_how(self) -> Result<Self::T, How>;
|
|
}
|
|
}
|
|
|
|
pub(crate) use private::IntoResultHow;
|
|
|
|
impl<T, E> IntoResultHow for Result<T, E>
|
|
where
|
|
E: std::error::Error,
|
|
{
|
|
type T = T;
|
|
|
|
#[inline]
|
|
fn into_result_how(self) -> Result<Self::T, How> {
|
|
self.map_err(|e| How::new(e.to_string()))
|
|
}
|
|
}
|
|
|
|
impl<T> IntoResultHow for Result<T, How> {
|
|
type T = T;
|
|
|
|
#[inline(always)]
|
|
fn into_result_how(self) -> Result<Self::T, How> {
|
|
self
|
|
}
|
|
}
|