dbg_pls/impls/std/
tuple.rs

1use crate::{DebugPls, Formatter};
2
3macro_rules! peel {
4    ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
5}
6
7macro_rules! tuple {
8    () => ();
9    ( $($name:ident,)* ) => (
10        impl<$($name:DebugPls),+> DebugPls for ($($name,)+) where last_type!($($name,)+): ?Sized {
11            #[allow(non_snake_case, unused_assignments)]
12            fn fmt(&self, f: Formatter<'_>) {
13                let ($(ref $name,)+) = *self;
14                f.debug_tuple()
15                $(
16                    .field(&$name)
17                )+
18                    .finish();
19            }
20        }
21        peel! { $($name,)+ }
22    )
23}
24
25macro_rules! last_type {
26    ($a:ident,) => { $a };
27    ($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) };
28}
29
30tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
31
32impl DebugPls for () {
33    fn fmt(&self, f: Formatter<'_>) {
34        f.debug_tuple().finish();
35    }
36}