No description
Find a file
2022-09-15 19:39:10 +02:00
.github/workflows better rust toolchain 2022-09-15 19:39:10 +02:00
src portable tests 2022-09-15 19:37:16 +02:00
.gitignore initial commit 2021-12-20 14:00:10 +01:00
Cargo.toml initial commit 2021-12-20 14:00:10 +01:00
LICENSE Create LICENSE 2021-12-22 18:46:16 +01:00
README.md add fancy indexing and getting 2021-12-21 12:04:42 +01:00
rust-toolchain.toml upgrade, lol 2022-09-15 19:32:40 +02:00

A Vec<T: ?Sized>

It's implemented by laying out the elements in memory contiguously like alloc::vec::Vec

Layout

A Vechonk is 4 usize long. It owns a single allocation, containing the elements and the metadata. The elements are laid out contiguously from the front, while the metadata is laid out contiguously from the back. Both grow towards the center until they meet and get realloced to separate them again.


            Vechonk<str>
            ╭──────────────────────────────────╮
            │ ptr   | len   | cap  | elem_size │
            ╰──────────────────────────────────╯
               │               │        │
               │               ╰────────│──────────────────────────────────────╮
               │                        │                                      │
               │               ╭────────╯                                      │
        Heap   ▼               ▼                                               ▼
        ╭────────────┬─────────┬─────────────────┬──────────────┬──────────────╮
value   │ "hello"    │ "uwu"   │  <uninit>       │ 0 - 5        │ 5 - 3        │
        ├────────────┼─────────┼─────────────────┼──────────────┼──────────────┤
 size   │ dynamic    │ dynamic │  rest of alloc  │ usize + meta │ usize + meta │
        ╰────────────┴─────────┴─────────────────┴──────────────┴──────────────╯
            ▲            ▲                          │              │
            ╰────────────│──────────────────────────╯              │
                         ╰─────────────────────────────────────────╯