Visualizing Rust's Vtables: How dyn Trait Works In Memory

16 points by ettolrach


gignico

Coming from C++, one of the most interesting features of Rust is the way dyn works, as explained here, by storing the vtable pointer together with the object pointer instead of inside the object. This is a better version of the “you don’t pay what you don’t use” principle.