str is fixed-size

This commit is contained in:
Mahdi Dibaiee 2022-06-17 15:46:01 +01:00
parent 70dac2b4b5
commit 0c7daf95a5

View File

@ -13,7 +13,7 @@ Today I and a friend went down a rabbit hole about Rust and how it manages the h
TL;DR: TL;DR:
`Box<str>` is a primitive `str` allocated on the heap, whereas `String` is actually a `Vec<unsigned char>`, also allocated on the heap, which allows for efficient removals and appendages. `Box<str>` (16 bytes) uses less memory than `String` (24 bytes). `Box<str>` is a fixed-size primitive `str` allocated on the heap, whereas `String` is actually a `Vec<unsigned char>`, also allocated on the heap, which allows for efficient removals and appendages. `Box<str>` (16 bytes) uses less memory than `String` (24 bytes).
------ ------