Skip to content

Commit 8695bc7

Browse files
committed
auto merge of #7223 : steveklabnik/rust/vec_initial_docs, r=pcwalton
Let's explain more of what this module is about, not just 'vectors.'
2 parents e94e4d5 + 538fbc3 commit 8695bc7

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

src/libstd/vec.rs

+47-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,53 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Vectors
11+
/*!
12+
13+
The `vec` module contains useful code to help work with vector values. Vectors are Rust's list
14+
type. Vectors contain zero or more values of homogeneous types:
15+
16+
~~~ {.rust}
17+
let int_vector = [1,2,3];
18+
let str_vector = ["one", "two", "three"];
19+
~~~
20+
21+
This is a big module, but for a high-level overview:
22+
23+
## Structs
24+
25+
Several structs that are useful for vectors, such as `VecIterator`, which
26+
represents iteration over a vector.
27+
28+
## Traits
29+
30+
A number of traits that allow you to accomplish tasks with vectors, like the
31+
`MutableVector` and `ImmutableVector` traits.
32+
33+
## Implementations of other traits
34+
35+
Vectors are a very useful type, and so there's tons of implementations of
36+
traits found elsewhere. Some notable examples:
37+
38+
* `Clone`
39+
* `Iterator`
40+
* `Zero`
41+
42+
## Function definitions
43+
44+
There are a number of different functions that take vectors, here are some
45+
broad categories:
46+
47+
* Modifying a vector, like `append` and `grow`.
48+
* Searching in a vector, like `bsearch`.
49+
* Iterating over vectors, like `each_permutation`.
50+
* Functional transformations on vectors, like `map` and `partition`.
51+
* Stack/queue operations, like `push`/`pop` and `shift`/`unshift`.
52+
* Cons-y operations, like `head` and `tail`.
53+
* Zipper operations, like `zip` and `unzip`.
54+
55+
And much, much more.
56+
57+
*/
1258

1359
#[warn(non_camel_case_types)];
1460

0 commit comments

Comments
 (0)