Skip to main content

re_byte_size/
tuple_sizes.rs

1use crate::SizeBytes;
2
3impl SizeBytes for () {
4    #[inline]
5    fn heap_size_bytes(&self) -> u64 {
6        0
7    }
8
9    #[inline]
10    fn is_pod() -> bool {
11        true
12    }
13}
14
15impl<T, U> SizeBytes for (T, U)
16where
17    T: SizeBytes,
18    U: SizeBytes,
19{
20    #[inline]
21    fn heap_size_bytes(&self) -> u64 {
22        let (a, b) = self;
23        a.heap_size_bytes() + b.heap_size_bytes()
24    }
25
26    #[inline]
27    fn is_pod() -> bool {
28        T::is_pod() && U::is_pod()
29    }
30}
31
32impl<T, U, V> SizeBytes for (T, U, V)
33where
34    T: SizeBytes,
35    U: SizeBytes,
36    V: SizeBytes,
37{
38    #[inline]
39    fn heap_size_bytes(&self) -> u64 {
40        let (a, b, c) = self;
41        a.heap_size_bytes() + b.heap_size_bytes() + c.heap_size_bytes()
42    }
43
44    #[inline]
45    fn is_pod() -> bool {
46        T::is_pod() && U::is_pod() && V::is_pod()
47    }
48}
49
50impl<T, U, V, W> SizeBytes for (T, U, V, W)
51where
52    T: SizeBytes,
53    U: SizeBytes,
54    V: SizeBytes,
55    W: SizeBytes,
56{
57    #[inline]
58    fn heap_size_bytes(&self) -> u64 {
59        let (a, b, c, d) = self;
60        a.heap_size_bytes() + b.heap_size_bytes() + c.heap_size_bytes() + d.heap_size_bytes()
61    }
62
63    #[inline]
64    fn is_pod() -> bool {
65        T::is_pod() && U::is_pod() && V::is_pod() && W::is_pod()
66    }
67}