]> git.proxmox.com Git - rustc.git/blame - src/doc/book/second-edition/src/ch08-00-common-collections.md
New upstream version 1.21.0+dfsg1
[rustc.git] / src / doc / book / second-edition / src / ch08-00-common-collections.md
CommitLineData
cc61c64b
XL
1# Common Collections
2
3Rust’s standard library includes a number of really useful data structures
4called *collections*. Most other data types represent one specific value, but
5collections can contain multiple values. Unlike the built-in array and tuple
6types, the data these collections point to is stored on the heap, which means
7the amount of data does not need to be known at compile time and can grow or
8shrink as the program runs. Each kind of collection has different capabilities
9and costs, and choosing an appropriate one for the situation you’re in is a
10skill you’ll develop over time. In this chapter, we’ll go over three
11collections which are used very often in Rust programs:
12
13* A *vector* allows us to store a variable number of values next to each other.
14* A *string* is a collection of characters. We’ve seen the `String` type
15 before, but we’ll talk about it in depth now.
3b2f2976 16* A *hash map* allows us to associate a value with a particular key. It’s a
cc61c64b
XL
17 particular implementation of the more general data structure called a *map*.
18
19To learn about the other kinds of collections provided by the standard library,
20see [the documentation][collections].
21
22[collections]: ../../std/collections/index.html
23
24We’re going to discuss how to create and update vectors, strings, and hash
25maps, as well as what makes each special.