Skip to content

Commit 64813d3

Browse files
committed
vectors are not in the language
1 parent c94d479 commit 64813d3

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/doc/reference.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,9 +2810,8 @@ array_expr : '[' "mut" ? vec_elems? ']' ;
28102810
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
28112811
```
28122812

2813-
An [array](#vector,-array,-and-slice-types) _expression_ is written by
2814-
enclosing zero or more comma-separated expressions of uniform type in square
2815-
brackets.
2813+
An [array](#array,-and-slice-types) _expression_ is written by enclosing zero
2814+
or more comma-separated expressions of uniform type in square brackets.
28162815

28172816
In the `[expr ',' ".." expr]` form, the expression after the `".."` must be a
28182817
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
28312830
idx_expr : expr '[' expr ']' ;
28322831
```
28332832

2834-
[Array](#vector,-array,-and-slice-types)-typed expressions can be indexed by
2833+
[Array](#array,-and-slice-types)-typed expressions can be indexed by
28352834
writing a square-bracket-enclosed expression (the index) after them. When the
28362835
array is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can
28372836
be assigned to.
@@ -3551,23 +3550,17 @@ let (a, b) = p;
35513550
assert!(b != "world");
35523551
```
35533552

3554-
### Vector, Array, and Slice types
3553+
### Array, and Slice types
35553554

3556-
Rust has three different types for a list of items:
3555+
Rust has two different types for a list of items:
35573556

3558-
* `Vec<T>`, a 'vector'
35593557
* `[T ..N]`, an 'array'
35603558
* `&[T]`, a 'slice'.
35613559

3562-
A vector is a heap-allocated list of `T`. A vector has ownership over the data
3563-
inside of it. It is also able to grow and change in size. It's important to
3564-
note that `Vec<T>` is a library type, it's not actually part of the core
3565-
language.
3566-
35673560
An array has a fixed size, and can be allocated on either the stack or the
35683561
heap.
35693562

3570-
A slice is a 'view' into a vector or array. It doesn't own the data it points
3563+
A slice is a 'view' into an array. It doesn't own the data it points
35713564
to, it borrows it.
35723565

35733566
An example of each kind:
@@ -3581,8 +3574,8 @@ let s: &[int] = vec.as_slice();
35813574
As you can see, the `vec!` macro allows you to create a `Vec<T>` easily. The
35823575
`vec!` macro is also part of the standard library, rather than the language.
35833576

3584-
All in-bounds elements of vectors, arrays, and slices are always initialized,
3585-
and access to a vector, array, or slice is always bounds-checked.
3577+
All in-bounds elements of arrays, and slices are always initialized, and access
3578+
to an array or slice is always bounds-checked.
35863579

35873580
### Structure types
35883581

@@ -3644,7 +3637,7 @@ enclosing `enum` or `struct` type itself. Such recursion has restrictions:
36443637

36453638
* Recursive types must include a nominal type in the recursion
36463639
(not mere [type definitions](#type-definitions),
3647-
or other structural types such as [arrays](#vector,-array,-and-slice-types) or [tuples](#tuple-types)).
3640+
or other structural types such as [arrays](#array,-and-slice-types) or [tuples](#tuple-types)).
36483641
* A recursive `enum` item must have at least one non-recursive constructor
36493642
(in order to give the recursion a basis case).
36503643
* The size of a recursive type must be finite;

0 commit comments

Comments
 (0)