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