diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-12-05 19:48:37 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-12-05 19:48:37 +0100 |
| commit | 72a9631b038d1a60e4e4a78e92cd69e6f8ce4316 (patch) | |
| tree | 17614efc2e21dd0b8caa24beaaaee7c40c150281 /src/macros.rs | |
| parent | f72b1505bebf8d2fe1a60d386a3a3c3b67d4f903 (diff) | |
Move arg parser into `FuncArgs` and create (incomplete) consistent map ðŸ§
Diffstat (limited to 'src/macros.rs')
| -rw-r--r-- | src/macros.rs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/macros.rs b/src/macros.rs index b6f069b7..ebe1cad7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -3,37 +3,33 @@ /// Create trait implementations for an error type. macro_rules! error_type { ( - $var:ident: $err:ident, + $this:ident: $type:ident, $(res: $res:ident,)* show: $f:ident => $show:expr, $(source: $source:expr,)* - $(from: ($from:path, $conv:expr),)* + $(from: ($err:ident: $from:path, $conv:expr),)* ) => { // Possibly create a result type. - $(type $res<T> = std::result::Result<T, $err>;)* + $(type $res<T> = std::result::Result<T, $type>;)* - impl std::fmt::Display for $err { - fn fmt(&self, $f: &mut std::fmt::Formatter) -> std::fmt::Result { - #[allow(unused)] - let $var = self; + impl std::fmt::Display for $type { + fn fmt(&$this, $f: &mut std::fmt::Formatter) -> std::fmt::Result { $show } } - debug_display!($err); + debug_display!($type); - impl std::error::Error for $err { + impl std::error::Error for $type { // The source method is only generated if an implementation was given. - $(fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - #[allow(unused)] - let $var = self; + $(fn source(&$this) -> Option<&(dyn std::error::Error + 'static)> { $source })* } // Create any number of from implementations. - $(impl From<$from> for $err { - fn from($var: $from) -> $err { + $(impl From<$from> for $type { + fn from($err: $from) -> $type { $conv } })* |
