Ferris, the Rust mascotRustacean

Home

❯

mocs

❯

Collections & Strings

Collections & Strings

Jun 21, 20261 min read

  • rust
  • collections
  • strings
  • moc

Collections & Strings

Collections and strings are Rust’s owned, borrowed, growable, and iterable building blocks for runtime-sized data.

Concepts

  • Vec
  • String and str
  • HashMap
  • BTreeMap and BTreeSet
  • VecDeque
  • Capacity and Reallocation
  • Set Collections with HashSet and BTreeSet
  • BinaryHeap Priority Queues
  • The Slice Type

Patterns

  • Borrowing Strings and Slices
  • The Entry API
  • Iterating Collections
  • Choosing Collection Types
  • Sorting and Binary Search on Slices

Antipatterns

  • String Byte Indexing
  • Holding Collection Element References Across Mutation
  • Stale Slice Indices

Adjacent Notes

Ownership · Borrowing · Dynamically Sized Types · Index Panics vs get · Needless Clone · Unnecessary Collect · Copy and Clone

Sources

  • The Rust Programming Language, ch. 8 “Common Collections” — the-book, https://doc.rust-lang.org/book/ch08-00-common-collections.html
  • Standard library collections overview — std, https://doc.rust-lang.org/std/collections/index.html
  • Standard library string module overview — std, https://doc.rust-lang.org/std/string/index.html

Graph View

  • Collections & Strings
  • Concepts
  • Patterns
  • Antipatterns
  • Adjacent Notes
  • Sources

Backlinks

  • Rust Brain Home
  • Holding Collection Element References Across Mutation
  • Implementing Borrow for Partial Views
  • String Byte Indexing
  • BTreeMap and BTreeSet
  • Capacity and Reallocation
  • HashMap
  • String and str
  • Vec
  • VecDeque
  • index
  • Idioms & API Design
  • std: Collections Deep
  • Borrow for Equivalent Keys
  • Borrowing Strings and Slices
  • Choosing Collection Types
  • Iterating Collections
  • The Entry API

Created with Quartz v4.5.2 © 2026

  • GitHub
  • Download (.zip)
  • Latest release