From 699cceadefdc18839cd16418684aaad7c5fca3c6 Mon Sep 17 00:00:00 2001 From: TalonsLee Date: Thu, 12 Dec 2024 23:02:54 +0800 Subject: [PATCH] Set the correct element type in vector (#2500) --- src/smart-pointers/trait-objects.md | 56 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/smart-pointers/trait-objects.md b/src/smart-pointers/trait-objects.md index 7f0e3f51..f66b27b6 100644 --- a/src/smart-pointers/trait-objects.md +++ b/src/smart-pointers/trait-objects.md @@ -48,34 +48,34 @@ Memory layout after allocating `pets`: ```bob Stack Heap -.- - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - - - - - - - - -. -: : : : -: "pets: Vec" : : "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 : - : | | +----------------------+ : - : | `----->| "::talk" | : - : | +----------------------+ : - : | vtable : - : | +----------------------+ : - : '----------->| "::talk" | : - : +----------------------+ : - : : - '- - - - - - - - - - - - - - - - - - - - - - -' +.- - - - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - - - - - - - - -. +: : : : +: "pets: Vec>" : : "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 : + : | | +----------------------+ : + : | `----->| "::talk" | : + : | +----------------------+ : + : | vtable : + : | +----------------------+ : + : '----------->| "::talk" | : + : +----------------------+ : + : : + '- - - - - - - - - - - - - - - - - - - - - - -' ```