I've implemented a way to store a type erased object instance with all associated traits and probably committed some crimes along the way

This page summarizes the projects mentioned and recommended in the original post on /r/rust

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • multi-trait-object

    A rust type to store an object with all associated traits

  • rfcs

    RFCs for changes to Rust

  • While this works, it is arguably not "safe," because there are no stability guarantees about the layout of fat pointers. Which is to say, rustc is permitted to silently change the layout of trait objects or other fat pointers at any time, making the transmute between a trait object and your FatPointer type unsound. The layout of trait objects has never changed thus far, but there are real proposals that would involve doing so (for example), and the layout is explicitly undefined for this reason.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • rust

    Empowering everyone to build reliable and efficient software.

  • The only way to interact with pointer metadata like this in a way that could be considered safe is through the ptr-metadata API, which is itself unstable and feature-gated (although an RFC has been merged, so I believe it is on a path to stabilization.)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts