The contents of Vec<T> , regardless of T , are a single heap distribution, self.capacity() * std::mem::size_of::<T>() bytes. ( Vec generalocates is the whole point of Vec<T> instead of Box<[T]> , as well as its capacity, not the length, which matters in this calculation.) The actual Vec<T> itself takes three words ( 24 bytes of 64 beat machine).
[f32; 5] [f32; 5] - this is just a piece of memory containing five 32-bit floating-point numbers, without indirection; this is twenty bytes (hence std::mem::size_of::<[f32; 5]>() == 20 ).
source share