mirror of
https://github.com/Noratrieb/vechonk.git
synced 2026-01-14 16:45:10 +01:00
ascii art uwu
This commit is contained in:
parent
ef6c357b27
commit
a7fbd67746
2 changed files with 34 additions and 34 deletions
36
README.md
36
README.md
|
|
@ -1,30 +1,30 @@
|
||||||
# A `Vec<T: ?Sized>`
|
# A `Vec<T: ?Sized>`
|
||||||
|
|
||||||
It's implemented by laying out the elements in memory contiguously like [`alloc::vec::Vec`]
|
It's implemented by laying out the elements in memory contiguously like `alloc::vec::Vec`
|
||||||
|
|
||||||
# Layout
|
# Layout
|
||||||
|
|
||||||
A [`Vechonk`] is 3 `usize` long. It owns a single allocation, containing the elements and the metadata.
|
A `Vechonk` is 3 `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.
|
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.
|
Both grow towards the center until they meet and get realloced to separate them again.
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
|
|
||||||
Vechonk<str>
|
Vechonk<str>
|
||||||
------------------------------------
|
╭──────────────────────────────────╮
|
||||||
| ptr | len | cap | elem_size |
|
│ ptr | len | cap | elem_size │
|
||||||
---|---------------|--------|-------
|
╰──────────────────────────────────╯
|
||||||
| | |
|
│ │ │
|
||||||
| |_______ | ______________________________________
|
│ ╰────────│──────────────────────────────────────╮
|
||||||
| | |
|
│ │ │
|
||||||
| _________| |
|
│ ╭────────╯ │
|
||||||
Heap v v v
|
Heap ▼ ▼ ▼
|
||||||
-----------------------|-----------------------------------------------
|
╭────────────┬─────────┬─────────────────┬──────────────┬──────────────╮
|
||||||
value | "hello" | "uwu" | <uninit> | 0 - 5 | 5 - 3 |
|
value │ "hello" │ "uwu" │ <uninit> │ 0 - 5 │ 5 - 3 │
|
||||||
|------------|---------|-----------------|--------------|--------------|
|
├────────────┼─────────┼─────────────────┼──────────────┼──────────────┤
|
||||||
size | dynamic | dynamic | rest of alloc | usize + meta | usize + meta |
|
size │ dynamic │ dynamic │ rest of alloc │ usize + meta │ usize + meta │
|
||||||
--------------------------------------------|--------------|------------
|
╰────────────┴─────────┴─────────────────┴──────────────┴──────────────╯
|
||||||
^ ^ | |
|
▲ ▲ │ │
|
||||||
|___________ | _________________________| |
|
╰────────────│──────────────────────────╯ │
|
||||||
|_________________________________________|
|
╰─────────────────────────────────────────╯
|
||||||
```
|
```
|
||||||
32
src/lib.rs
32
src/lib.rs
|
|
@ -16,22 +16,22 @@
|
||||||
//! ```txt
|
//! ```txt
|
||||||
//!
|
//!
|
||||||
//! Vechonk<str>
|
//! Vechonk<str>
|
||||||
//! ------------------------------------
|
//! ╭──────────────────────────────────╮
|
||||||
//! | ptr | len | cap | elem_size |
|
//! │ ptr | len | cap | elem_size │
|
||||||
//! ---|---------------|--------|-------
|
//! ╰──────────────────────────────────╯
|
||||||
//! | | |
|
//! │ │ │
|
||||||
//! | |_______ | ______________________________________
|
//! │ ╰────────│──────────────────────────────────────╮
|
||||||
//! | | |
|
//! │ │ │
|
||||||
//! | _________| |
|
//! │ ╭────────╯ │
|
||||||
//! Heap v v v
|
//! Heap ▼ ▼ ▼
|
||||||
//! -----------------------|-----------------------------------------------
|
//! ╭────────────┬─────────┬─────────────────┬──────────────┬──────────────╮
|
||||||
//! value | "hello" | "uwu" | <uninit> | 0 - 5 | 5 - 3 |
|
//! value │ "hello" │ "uwu" │ <uninit> │ 0 - 5 │ 5 - 3 │
|
||||||
//! |------------|---------|-----------------|--------------|--------------|
|
//! ├────────────┼─────────┼─────────────────┼──────────────┼──────────────┤
|
||||||
//! size | dynamic | dynamic | rest of alloc | usize + meta | usize + meta |
|
//! size │ dynamic │ dynamic │ rest of alloc │ usize + meta │ usize + meta │
|
||||||
//! --------------------------------------------|--------------|------------
|
//! ╰────────────┴─────────┴─────────────────┴──────────────┴──────────────╯
|
||||||
//! ^ ^ | |
|
//! ▲ ▲ │ │
|
||||||
//! |___________ | _________________________| |
|
//! ╰────────────│──────────────────────────╯ │
|
||||||
//! |_________________________________________|
|
//! ╰─────────────────────────────────────────╯
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
mod test;
|
mod test;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue