- Published on
Investigation · Part 5 of 10 · Types under the hood
Behavior Without Shape: Traits, Interfaces, and Types That Own No Bytes
A trait is the behavior half of a type with no shape at all. I measured a type of zero bytes carrying a trait, a million of them in a Vec with zero allocations, and a door that cannot be walked through while closed, all with nothing left in the binary. This is the kind of type I think most code does not use enough.