re_byte_size 0.34.0-rc.2

Calculate the heap-allocated size of values at runtime.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use egui::emath;

use crate::SizeBytes;

impl<T: SizeBytes + Copy> SizeBytes for emath::History<T> {
    fn heap_size_bytes(&self) -> u64 {
        let s = std::mem::size_of::<(f64, T)>() as u64 * self.len() as u64;
        if T::IS_POD {
            s
        } else {
            s + self
                .iter()
                .map(|t: (f64, T)| t.heap_size_bytes())
                .sum::<u64>()
        }
    }
}