Visualizing memory layout of Rust's data types(youtube.com) |
Visualizing memory layout of Rust's data types(youtube.com) |
It hasn't really been a major issue for me, but occasionally I've really wanted to get the vtable from a fat pointer and I've resorted to workarounds or just biting the bullet and using the de-facto standard layout that everyone knows (and statically asserting that it's a valid assumption for all types <T> that are used).
Note that pointer provenance can also break a lot of seemingly-valid assumptions too.
Understanding the layout of these types is helpful and useful, but keep in mind the caveat that these are technically subject to change.
Some fun reading links if this is interesting:
- https://github.com/rust-lang/rust/issues/75091
1) The pointer provenance you're referring to, is that CHERI or the pointer provenance currently in use in macOS?
2) Reading through your post, are you talking about the same as the anyhow's error implementation? https://github.com/dtolnay/anyhow/blob/af0937ef72fbaf9784a6c...