Summary
The Rust standard library features a great collections part, providing a few highly optimized implementations of basic data structures.
We started with Vec<T> and VecDeque<T>, both based on a heap-allocated array and wrapped in the RawVec<T> structure. They show excellent performance while memory efficiency remains high, thanks to the array base and unsafe operations based on pointers.
LinkedList<T> is a doubly-linked list that performs really well, thanks to direct data manipulation and the lack of runtime checking. While it excels at splitting and merging, most other operations are slower than Vec<T> and it lacks some useful features.
HashSet and HashMap are based on the same implementation (HashMap) and—unless specified differently—use ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access