defmt/impls/
tuples.rs

1use super::*;
2use crate::export;
3
4impl Format for () {
5    default_format!();
6
7    #[inline]
8    fn _format_tag() -> Str {
9        internp!("()")
10    }
11
12    #[inline]
13    fn _format_data(&self) {}
14}
15
16macro_rules! tuple {
17    ( $format:expr, ($($name:ident),+) ) => (
18        impl<$($name:Format),+> Format for ($($name,)+) where last_type!($($name,)+): ?Sized {
19            default_format!();
20
21            #[inline]
22            fn _format_tag() -> Str {
23                internp!($format)
24            }
25
26            #[inline]
27            #[allow(non_snake_case, unused_assignments)]
28            fn _format_data(&self) {
29                let ($(ref $name,)+) = *self;
30                $(
31                    export::istr(&$name::_format_tag());
32                    $name._format_data();
33                )+
34            }
35        }
36    )
37}
38
39macro_rules! last_type {
40    ($a:ident,) => { $a };
41    ($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) };
42}
43
44tuple! { "({=?})", (T0) }
45tuple! { "({=?}, {=?})", (T0, T1) }
46tuple! { "({=?}, {=?}, {=?})", (T0, T1, T2) }
47tuple! { "({=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3) }
48tuple! { "({=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4) }
49tuple! { "({=?}, {=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4, T5) }
50tuple! { "({=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4, T5, T6) }
51tuple! { "({=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4, T5, T6, T7) }
52tuple! { "({=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4, T5, T6, T7, T8) }
53tuple! { "({=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) }
54tuple! { "({=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) }
55tuple! { "({=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?}, {=?})", (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) }