@@ -2810,9 +2810,8 @@ array_expr : '[' "mut" ? vec_elems? ']' ;
2810
2810
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
2811
2811
```
2812
2812
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.
2816
2815
2817
2816
In the ` [expr ',' ".." expr] ` form, the expression after the ` ".." ` must be a
2818
2817
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
2831
2830
idx_expr : expr '[' expr ']' ;
2832
2831
```
2833
2832
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
2835
2834
writing a square-bracket-enclosed expression (the index) after them. When the
2836
2835
array is mutable, the resulting [ lvalue] ( #lvalues,-rvalues-and-temporaries ) can
2837
2836
be assigned to.
@@ -3551,23 +3550,17 @@ let (a, b) = p;
3551
3550
assert!(b != "world");
3552
3551
```
3553
3552
3554
- ### Vector, Array, and Slice types
3553
+ ### Array, and Slice types
3555
3554
3556
- Rust has three different types for a list of items:
3555
+ Rust has two different types for a list of items:
3557
3556
3558
- * ` Vec<T> ` , a 'vector'
3559
3557
* ` [T ..N] ` , an 'array'
3560
3558
* ` &[T] ` , a 'slice'.
3561
3559
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
-
3567
3560
An array has a fixed size, and can be allocated on either the stack or the
3568
3561
heap.
3569
3562
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
3571
3564
to, it borrows it.
3572
3565
3573
3566
An example of each kind:
@@ -3581,8 +3574,8 @@ let s: &[int] = vec.as_slice();
3581
3574
As you can see, the ` vec! ` macro allows you to create a ` Vec<T> ` easily. The
3582
3575
` vec! ` macro is also part of the standard library, rather than the language.
3583
3576
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.
3586
3579
3587
3580
### Structure types
3588
3581
@@ -3644,7 +3637,7 @@ enclosing `enum` or `struct` type itself. Such recursion has restrictions:
3644
3637
3645
3638
* Recursive types must include a nominal type in the recursion
3646
3639
(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 ) ).
3648
3641
* A recursive ` enum ` item must have at least one non-recursive constructor
3649
3642
(in order to give the recursion a basis case).
3650
3643
* The size of a recursive type must be finite;
0 commit comments