You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# 通用集合类型
> [ch08-00-common-collections.md](https://github.com/rust-lang/book/blob/master/second-edition/src/ch08-00-common-collections.md)
> <br>
> commit e6d6caab41471f7115a621029bd428a812c5260e
Rust 标准库中包含一系列被称为**集合**( *collections*)的非常有用的数据结构。大部分其他数据类型都代表一个特定的值,不过集合可以包含多个值。不同于内建的数组和元组类型,这些集合指向的数据是储存在堆上的,这意味着数据的数量不必在编译时就可知并且可以随着程序的运行增长或缩小。每种集合都有着不同能力和代价,而为所处的场景选择合适的集合则是你将要始终发展的技能。在这一章里,我们将详细的了解三个在 Rust 程序中被广泛使用的集合:
* *vector* 允许我们一个挨着一个地储存一系列数量可变的值
* **字符串**( *string*)是一个字符的集合。我们之前见过`String`类型,现在将详细介绍它。
* **哈希 map**( *hash map*) 允许我们将值与一个特定的键( key) 相关联。这是一个叫做 *map* 的更通用的数据结构的特定实现。
对于标准库提供的其他类型的集合,请查看[文档][collections]。
[collections]: https://doc.rust-lang.org/std/collections
我们将讨论如何创建和更新 vector、字符串和哈希 map, 以及他们有什么不同。