pub struct Errorlike<T>(pub T);Expand description
Errorlike is a newtype for conditionally implementing the Error trait on types that
satisfy Debug and Display but do not implement Error directly.
This is used when you need to return an Error, but don’t have one handy.
§Examples
use std::error::Error;
use serbzip_core::succinct::CowStr;
use serbzip_core::succinct::Errorlike;
fn main() -> Result<(), Box<dyn Error>> {
if something_wrong() {
return Err(Errorlike("something awful just happened"))?;
}
Ok(())
}Tuple Fields§
§0: TImplementations§
Trait Implementations§
Source§impl<T: Display + Debug> Error for Errorlike<T>
impl<T: Display + Debug> Error for Errorlike<T>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<Errorlike<Cow<'static, str>>> for ReadFromTextFileError
impl From<Errorlike<Cow<'static, str>>> for ReadFromTextFileError
Source§fn from(error: OverflowError) -> Self
fn from(error: OverflowError) -> Self
Converts to this type from the input type.
impl<T: Eq> Eq for Errorlike<T>
impl<T> StructuralPartialEq for Errorlike<T>
Auto Trait Implementations§
impl<T> Freeze for Errorlike<T>where
T: Freeze,
impl<T> RefUnwindSafe for Errorlike<T>where
T: RefUnwindSafe,
impl<T> Send for Errorlike<T>where
T: Send,
impl<T> Sync for Errorlike<T>where
T: Sync,
impl<T> Unpin for Errorlike<T>where
T: Unpin,
impl<T> UnwindSafe for Errorlike<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more