mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-19 22:19:29 +02:00
Do not show trait vtables as located in the heap in memory diagram (#1882)
This diagram is misleading and I often explain that the character data of string literals resides in the executable's static data, with vtables working the same.
This commit is contained in:
parent
976f6f6f24
commit
42f6e1186e
@ -48,30 +48,30 @@ Memory layout after allocating `pets`:
|
||||
Stack Heap
|
||||
.- - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - - - - - - - - -.
|
||||
: : : :
|
||||
: pets : : +----+----+----+----+ :
|
||||
: +-----------+-------+ : : +-----+-----+ .->| F | i | d | o | :
|
||||
: | ptr | o---+---+-----+-->| o o | o o | | +----+----+----+----+ :
|
||||
: | len | 2 | : : +-|-|-+-|-|-+ `---------. :
|
||||
: | capacity | 2 | : : | | | | data | :
|
||||
: +-----------+-------+ : : | | | | +-------+--|-------+ :
|
||||
: : : | | | '-->| name | o, 4, 4 | :
|
||||
: : : | | | | age | 5 | :
|
||||
`- - - - - - - - - - - - - -' : | | | +-------+----------+ :
|
||||
: | | | :
|
||||
: | | | vtable :
|
||||
: | | | +----------------------+ :
|
||||
: | | '---->| "<Dog as Pet>::talk" | :
|
||||
: | | +----------------------+ :
|
||||
: | | :
|
||||
: | | data :
|
||||
: | | +-------+-------+ :
|
||||
: | '-->| lives | 9 | :
|
||||
: | +-------+-------+ :
|
||||
: | :
|
||||
: | vtable :
|
||||
: | +----------------------+ :
|
||||
: '---->| "<Cat as Pet>::talk" | :
|
||||
: +----------------------+ :
|
||||
: "pets: Vec<dyn Pet>" : : "data: Cat" +----+----+----+----+ :
|
||||
: +-----------+-------+ : : +-------+-------+ | F | i | d | o | :
|
||||
: | ptr | o---+---+--. : | lives | 9 | +----+----+----+----+ :
|
||||
: | len | 2 | : | : +-------+-------+ ^ :
|
||||
: | capacity | 2 | : | : ^ | :
|
||||
: +-----------+-------+ : | : | '-------. :
|
||||
: : | : | data:"Dog"| :
|
||||
: : | : | +-------+--|-------+ :
|
||||
`- - - - - - - - - - - - - -' | : +---|-+-----+ | name | o, 4, 4 | :
|
||||
`--+-->| o o | o o-|----->| age | 5 | :
|
||||
: +-|---+-|---+ +-------+----------+ :
|
||||
: | | :
|
||||
`- - -| - - |- - - - - - - - - - - - - - - - -'
|
||||
| |
|
||||
| | "Program text"
|
||||
.- - -| - - |- - - - - - - - - - - - - - - - -.
|
||||
: | | vtable :
|
||||
: | | +----------------------+ :
|
||||
: | `----->| "<Dog as Pet>::talk" | :
|
||||
: | +----------------------+ :
|
||||
: | vtable :
|
||||
: | +----------------------+ :
|
||||
: '----------->| "<Cat as Pet>::talk" | :
|
||||
: +----------------------+ :
|
||||
: :
|
||||
'- - - - - - - - - - - - - - - - - - - - - - -'
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user