Handle anyhow::Error as argument to anyhow!()

This commit is contained in:
David Tolnay 2019-11-18 11:39:26 -08:00
parent 59fb765bab
commit 210e60a8c4
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -45,7 +45,6 @@
// (&error).anyhow_kind().new(error)
use crate::Error;
use std::error::Error as StdError;
use std::fmt::{Debug, Display};
#[cfg(backtrace)]
@ -80,13 +79,13 @@ pub trait TraitKind: Sized {
}
}
impl<T> TraitKind for T where T: StdError + Send + Sync + 'static {}
impl<E> TraitKind for E where E: Into<Error> {}
impl Trait {
pub fn new<E>(self, error: E) -> Error
where
E: StdError + Send + Sync + 'static,
E: Into<Error>,
{
Error::from_std(error, backtrace!())
error.into()
}
}