FFI-Safe Polymorphism: Thin Trait Objects

Over the last week or two I've been playing around with an idea I call Thin Trait Objects and thought I'd do a write-up about it.

It's essentially a technique for creating a trait object (e.g. Box<dyn Write>) which is safe for use across the FFI boundary and can be represented using a normal ("thin") pointer instead of a fat pointer.

You may also find this article educational if you want to know how other languages implement dynamic dispatch (e.g. trait objects or virtual methods), and how you can have inheritance in a non-OO language like C or Rust.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.