#collections

7 articles about collections

rustAugust 27, 2025

Vec::push() in a loop vs. pre-allocating with Vec::with_capacity()?

Comparing performance of Vec::push() in loops versus pre-allocating with Vec::with_capacity(), analyzing memory reallocation costs and optimization strategies

rustJuly 24, 2025

What is the difference between Box<[T]> and Vec<T>?

Comparing Box<[T]> and Vec<T> differences in mutability, memory overhead, and performance implications for different use cases

rustJuly 21, 2025

How do you remove duplicates from a Vec<T> where T: Eq + Hash?

Efficient approaches to remove duplicates from Vec<T> where T: Eq + Hash, comparing HashSet-based and sort-based methods with performance analysis

rustJuly 16, 2025

Rust's collect() Magic: Turning Iterators into Vecs, HashMaps, and Strings!

How collect() decides what to build, what FromIterator asks of the target type, and how to steer it towards a Vec, a HashMap or a String.

rustJuly 14, 2025

Implications of iterating over a Vec with .into_iter() instead of .iter()

Understanding the differences between .into_iter() and .iter() when iterating over Vec, covering ownership implications and performance considerations

rustJuly 8, 2025

How do into_iter(), iter(), and iter_mut() differ?

into_iter(), iter() and iter_mut() differ in what they hand you: the value, a shared reference, or an exclusive one.

rustJune 25, 2025

Rust Vec::new() vs. with_capacity(): When to Use Each

Vec allocation strategies in Rust, comparing Vec::new() and Vec::with_capacity() for optimal performance.