diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2014-09-19 17:02:54 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2014-09-22 17:54:10 -0400 |
| commit | 64813d33d825cbd155ef237accc9fe8c8b670ed2 (patch) | |
| tree | 18574a50a9d75b12caea78a388c6367f633536ed | |
| parent | c94d479a90ab4e99926ac218d1b2329056c7e04b (diff) | |
| download | rust-64813d33d825cbd155ef237accc9fe8c8b670ed2.tar.gz rust-64813d33d825cbd155ef237accc9fe8c8b670ed2.zip | |
vectors are not in the language
| -rw-r--r-- | src/doc/reference.md | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 82d17066aa8..d56c8286fcb 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2810,9 +2810,8 @@ array_expr : '[' "mut" ? vec_elems? ']' ; array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ; ``` -An [array](#vector,-array,-and-slice-types) _expression_ is written by -enclosing zero or more comma-separated expressions of uniform type in square -brackets. +An [array](#array,-and-slice-types) _expression_ is written by enclosing zero +or more comma-separated expressions of uniform type in square brackets. In the `[expr ',' ".." expr]` form, the expression after the `".."` must be a constant expression that can be evaluated at compile time, such as a @@ -2831,7 +2830,7 @@ constant expression that can be evaluated at compile time, such as a idx_expr : expr '[' expr ']' ; ``` -[Array](#vector,-array,-and-slice-types)-typed expressions can be indexed by +[Array](#array,-and-slice-types)-typed expressions can be indexed by writing a square-bracket-enclosed expression (the index) after them. When the array is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can be assigned to. @@ -3551,23 +3550,17 @@ let (a, b) = p; assert!(b != "world"); ``` -### Vector, Array, and Slice types +### Array, and Slice types -Rust has three different types for a list of items: +Rust has two different types for a list of items: -* `Vec<T>`, a 'vector' * `[T ..N]`, an 'array' * `&[T]`, a 'slice'. -A vector is a heap-allocated list of `T`. A vector has ownership over the data -inside of it. It is also able to grow and change in size. It's important to -note that `Vec<T>` is a library type, it's not actually part of the core -language. - An array has a fixed size, and can be allocated on either the stack or the heap. -A slice is a 'view' into a vector or array. It doesn't own the data it points +A slice is a 'view' into an array. It doesn't own the data it points to, it borrows it. An example of each kind: @@ -3581,8 +3574,8 @@ let s: &[int] = vec.as_slice(); As you can see, the `vec!` macro allows you to create a `Vec<T>` easily. The `vec!` macro is also part of the standard library, rather than the language. -All in-bounds elements of vectors, arrays, and slices are always initialized, -and access to a vector, array, or slice is always bounds-checked. +All in-bounds elements of arrays, and slices are always initialized, and access +to an array or slice is always bounds-checked. ### Structure types @@ -3644,7 +3637,7 @@ enclosing `enum` or `struct` type itself. Such recursion has restrictions: * Recursive types must include a nominal type in the recursion (not mere [type definitions](#type-definitions), - or other structural types such as [arrays](#vector,-array,-and-slice-types) or [tuples](#tuple-types)). + or other structural types such as [arrays](#array,-and-slice-types) or [tuples](#tuple-types)). * A recursive `enum` item must have at least one non-recursive constructor (in order to give the recursion a basis case). * The size of a recursive type must be finite; |
