|
|
@ -1,25 +1,6 @@ |
|
|
|
use std::convert::Infallible; |
|
|
|
|
|
|
|
use std::error::Error; |
|
|
|
use std::error::Error; |
|
|
|
use std::io; |
|
|
|
use std::io; |
|
|
|
|
|
|
|
|
|
|
|
/// Traits that allows unwrapping only infallible results
|
|
|
|
|
|
|
|
pub trait UnwrapInfallible { |
|
|
|
|
|
|
|
type Value; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn unwrap_infallible(self) -> Self::Value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<T> UnwrapInfallible for Result<T, Infallible> { |
|
|
|
|
|
|
|
type Value = T; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn unwrap_infallible(self) -> T { |
|
|
|
|
|
|
|
match self { |
|
|
|
|
|
|
|
Ok(value) => value, |
|
|
|
|
|
|
|
Err(error) => match error {}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn invalid_data_error(error: impl Into<Box<dyn Error + Send + Sync>>) -> io::Error { |
|
|
|
pub fn invalid_data_error(error: impl Into<Box<dyn Error + Send + Sync>>) -> io::Error { |
|
|
|
io::Error::new(io::ErrorKind::InvalidData, error) |
|
|
|
io::Error::new(io::ErrorKind::InvalidData, error) |
|
|
|
} |
|
|
|
} |
|
|
|