This is such a helpful diagram, showing the layout of common #RustLang pointers/containers in memory. I think this sort of thing should be in The Book. If it strikes you as too advanced for that audience, think about how hard it is for beginners to navigate the constant barrage of `Sized` bounds without this mental model.
@dpom hmmm i'd prefer if it said the number of bits instead of bytes. 32/64 bits is much more clearly associated with architecture than 4/8 bytes
@dpom I think that this really shows just how much that the existing baggage of being taught "how computers work" in another language like C or Java impairs people's ability to understand how things work in a different language
like it is absolutely wild to me that people feel the need to understand the layout of Vec
in Rust to the point they think it needs to be in the introductory book. nobody using Java or C# needs to understand the layout of ArrayList, or boxed Integers, to have a mental model of the language. but for some reason, Rust doing things differently gives it the burden to explain things in terms like this
to clarify, I'm not blaming you or anyone in particular for this; it's a systemic problem. I just think it's a ridiculous problem
@clarfonthey @dpom There is an advanced features section of the book. While the book has an introduction, I don't think the book is intended to be only introductory, at least that was my impression. So I don't think suggesting it be in the book implies that knowing memory layouts is required to learn to use Rust. (Though it is helpful in any language)
@dpom Thanks, glad you like it! The main reason it's not in The Book is that it makes concrete some choices that are not actually required by the language. And in particular the Mutex is either likely to change or already has, thanks to the work in parking_lot.
I made it largely to help experienced C++ programmers (at Google), and think it was particularly helpful for that audience.
@dpom Noice!
How up to date is the Mutex part? I remember that Mara was posting of switching from boxed pthread mutexes to native implementation with futex.
@ldvsoft @dpom I was about to say the same thing.
Also I tried something similar using Mermaid but Reveal.js and Mermaid fight and the diagrams often don’t load:
https://rust-training.ferrous-systems.com/latest/slides/collections
There’s a summary table at the end.