I'm revisiting some of the basic types (and smart pointers), and I decided to make a simple Rust program to printout the details for each of them, with some types it's working ok yielding correct info, but when it comes to the Rc type, it's Deref trait implementation returns a private type, that I cannot somewhat get the details of (I'd expect to have memory for both reference counts + a ptr to the actual data)
I haven't looked at your code, but note that Rc does store the data next to the reference counts, there is no second indirection.
So an Rc<u32> is a pointer to a memory location where the reference counts are stored directly next to the value of the u32 itself. Also note - in case that isn't clear - that the layout of Rc (both the Rc itself, and also the struct it points to that contains the reference counts and the data) is not stable, so programs must not rely on these implementation details. (But it can be useful for learning-purposes, of course.)
So in practice, the length in question of RcBox<u32> is likely going to be (on a 64-bit machine): 2*8 bytes for the 2 counters, and 4 bytes for the u32 value, plus additional 4 bytes padding to get a multiple of 8, i.e. 32 bytes total.
My intention is for the program to be standalone, so that without intervention it can print out all the correct values. This way, without changing the code, it will be able to dump the sizes for each type no matter the rust version is compiled with
It's not an official website, but it should be up-to-date, and it's super useful for inspecting implementation details of std as private and hidden documentation is included, and the linked source code has hyperlinks enabled.