Macro trackable::derive_traits_for_trackable_error_newtype [] [src]

macro_rules! derive_traits_for_trackable_error_newtype {
    ($error:ty, $kind:ty) => { ... };
}

Implements the typical traits for a newtype $error of TrackableError<$kind>.

The automatically implemented traits are Deref, From, Display, Error, Trackable and IntoTrackableError.

This macro is useful to reduce the boilerplate code when you define a your own trackable error type.

Examples

use trackable::error::{TrackableError, ErrorKind as TrackableErrorKind};

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ErrorKind {
   Foo,
   Bar,
   Baz,
}
impl TrackableErrorKind for ErrorKind {}

// Defines a newtype of `TrackableError<ErrorKind>`.
//
// NOTE:
// If there is no need to implement your own features for the new error type,
// it is more concise to use aliasing (i.e., `pub type Error = ...`)
// instead of newtype pattern.
#[derive(Debug, Clone)]
pub struct Error(TrackableError<ErrorKind>);
derive_traits_for_trackable_error_newtype!(Error, ErrorKind);