Mehdi Akiki

Posts tagged "traits"

  • 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.
  • Published on

    Reference · Through the layers

    Solving the Multi-Trait Object Problem in Rust

    Learn how to work around Rust’s limitation of multi-trait objects by using a composite trait to combine multiple traits like `Read` and `Seek` into a single dynamic object.