+ // Debug is requested for derive, don't generate any Debug implementation.
+ (@handle_debug
+ @derives [Debug, $($derives:ident,)*]
+ @type [$type:ident]
+ @debug_format [$debug_format:expr]) => ();
+
+ // It's not Debug, so just pop it off the front of the derives stack and check the rest.
+ (@handle_debug
+ @derives [$_derive:ident, $($derives:ident,)*]
+ @type [$type:ident]
+ @debug_format [$debug_format:expr]) => (
+ newtype_index!(
+ @handle_debug
+ @derives [$($derives,)*]
+ @type [$type]
+ @debug_format [$debug_format]);
+ );
+
+ // Append comma to end of derives list if it's missing
+ (@type [$type:ident]
+ @pub [$($pub:tt)*]
+ @max [$max:expr]
+ @debug_format [$debug_format:expr]
+ derive [$($derives:ident),*]
+ $($tokens:tt)*) => (
+ newtype_index!(
+ @type [$type]
+ @pub [$($pub)*]
+ @max [$max]
+ @debug_format [$debug_format]
+ derive [$($derives,)*]
+ $($tokens)*);
+ );
+
+ // By not including the @derives marker in this list nor in the default args, we can force it
+ // to come first if it exists. When encodable is custom, just use the derives list as-is.
+ (@type [$type:ident]
+ @pub [$($pub:tt)*]
+ @max [$max:expr]
+ @debug_format [$debug_format:expr]
+ derive [$($derives:ident,)+]
+ ENCODABLE = custom
+ $($tokens:tt)*) => (
+ newtype_index!(
+ @derives [$($derives,)+]
+ @type [$type]
+ @pub [$($pub)*]
+ @max [$max]
+ @debug_format [$debug_format]
+ $($tokens)*);
+ );
+