Our great sponsors
-
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.
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.
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.)