Using a slab

Some algorithms require you to hold access tokens to data that may or may not exist. This could be solved in Rust by using  Vec<Option<T>>, and treating the index of your data as a token. But we can do better! slab is an optimized abstraction of exactly this concept.

While it is not meant as a general-purpose collection, slab can help you a lot if you use it in the right places.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.103.204