]>
git.proxmox.com Git - rustc.git/blob - src/vendor/failure/src/compat.rs
1 use core
::fmt
::{self, Display}
;
3 /// A compatibility wrapper around an error type from this crate.
5 /// `Compat` implements `std::error::Error`, allowing the types from this
6 /// crate to be passed to interfaces that expect a type of that trait.
7 #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
12 impl<E
: Display
> Display
for Compat
<E
> {
13 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
14 Display
::fmt(&self.error
, f
)
19 /// Unwraps this into the inner error.
20 pub fn into_inner(self) -> E
{
27 use std
::error
::Error
as StdError
;
31 impl<E
: Display
+ Debug
> StdError
for Compat
<E
> {
32 fn description(&self) -> &'
static str {
33 "An error has occurred."
37 impl From
<Error
> for Box
<StdError
> {
38 fn from(error
: Error
) -> Box
<StdError
> {
39 Box
::new(Compat { error }
)