Files
docs-rust/ch08/ch08-00-common-collections.html
2026-06-22 21:27:36 +05:30

31 lines
1.6 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Common Collections</title>
</head>
<body>
<h1 id="common-collections"><a class="header" href="#common-collections">Common Collections</a></h1>
<p>Rusts standard library includes a number of very useful data structures called
<em>collections</em>. Most other data types represent one specific value, but
collections can contain multiple values. Unlike the built-in array and tuple
types, the data that these collections point to is stored on the heap, which
means the amount of data does not need to be known at compile time and can grow
or shrink as the program runs. Each kind of collection has different
capabilities and costs, and choosing an appropriate one for your current
situation is a skill youll develop over time. In this chapter, well discuss
three collections that are used very often in Rust programs:</p>
<ul>
<li>A <em>vector</em> allows you to store a variable number of values next to each other.</li>
<li>A <em>string</em> is a collection of characters. Weve mentioned the <code>String</code> type
previously, but in this chapter, well talk about it in depth.</li>
<li>A <em>hash map</em> allows you to associate a value with a specific key. Its a
particular implementation of the more general data structure called a <em>map</em>.</li>
</ul>
<p>To learn about the other kinds of collections provided by the standard library,
see <a href="../std/collections/index.html">the documentation</a>.</p>
<p>Well discuss how to create and update vectors, strings, and hash maps, as well
as what makes each special.</p>
</body>
</html>