use std::error::Error;
use std::fmt;
use std::ops::Deref;
use std::rc::Rc;
pub struct RcError<T: Error>(Rc<T>);
impl<T: Error> AsRef<T> for RcError<T> {
#[inline]
fn as_ref(&self) -> &T {
self.0.as_ref()
}
}
impl<T: Error> fmt::Display for RcError<T> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<T as fmt::Display>::fmt(self.0.as_ref(), f)
}
}
impl<T: Error> fmt::Debug for RcError<T> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<T as fmt::Debug>::fmt(self.0.as_ref(), f)
}
}
impl<T: Error> Error for RcError<T> {}
impl<T: Error> From<T> for RcError<T> {
#[inline]
fn from(inner: T) -> Self {
Self(Rc::new(inner))
}
}
impl<T: Error> Clone for RcError<T> {
#[inline]
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: Error> Deref for RcError<T> {
type Target = T;
#[inline]
fn deref(&self) -> &Self::Target {
self.0.deref()
}
}