Skip to content

Commit faf14ae

Browse files
committed
Fix vector terminology in the manual.
fixes #17148
1 parent 6511064 commit faf14ae

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/doc/rust.md

+21-20
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ enclosed within two `U+0022` (double-quote) characters,
349349
with the exception of `U+0022` itself,
350350
which must be _escaped_ by a preceding `U+005C` character (`\`),
351351
or a _raw byte string literal_.
352-
It is equivalent to a `&'static [u8]` borrowed vector of unsigned 8-bit integers.
352+
It is equivalent to a `&'static [u8]` borrowed array of unsigned 8-bit integers.
353353

354354
Some additional _escapes_ are available in either byte or non-raw byte string
355355
literals. An escape starts with a `U+005C` (`\`) and continues with one of
@@ -2809,16 +2809,17 @@ When the type providing the field inherits mutabilty, it can be [assigned](#assi
28092809
Also, if the type of the expression to the left of the dot is a pointer,
28102810
it is automatically dereferenced to make the field access possible.
28112811

2812-
### Vector expressions
2812+
### Array expressions
28132813

28142814
~~~~ {.ebnf .gram}
2815-
vec_expr : '[' "mut" ? vec_elems? ']' ;
2815+
array_expr : '[' "mut" ? vec_elems? ']' ;
28162816
2817-
vec_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
2817+
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
28182818
~~~~
28192819

2820-
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
2821-
more comma-separated expressions of uniform type in square brackets.
2820+
An [array](#vector,-array,-and-slice-types) _expression_ is written by
2821+
enclosing zero or more comma-separated expressions of uniform type in square
2822+
brackets.
28222823

28232824
In the `[expr ',' ".." expr]` form, the expression after the `".."`
28242825
must be a constant expression that can be evaluated at compile time, such
@@ -2827,7 +2828,7 @@ as a [literal](#literals) or a [static item](#static-items).
28272828
~~~~
28282829
[1i, 2, 3, 4];
28292830
["a", "b", "c", "d"];
2830-
[0i, ..128]; // vector with 128 zeros
2831+
[0i, ..128]; // array with 128 zeros
28312832
[0u8, 0u8, 0u8, 0u8];
28322833
~~~~
28332834

@@ -2837,9 +2838,9 @@ as a [literal](#literals) or a [static item](#static-items).
28372838
idx_expr : expr '[' expr ']' ;
28382839
~~~~
28392840

2840-
[Vector](#vector-types)-typed expressions can be indexed by writing a
2841+
[Array](#vector,-array,-and-slice-types)-typed expressions can be indexed by writing a
28412842
square-bracket-enclosed expression (the index) after them. When the
2842-
vector is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can be assigned to.
2843+
array is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can be assigned to.
28432844

28442845
Indices are zero-based, and may be of any integral type. Vector access
28452846
is bounds-checked at run-time. When the check fails, it will put the
@@ -2900,7 +2901,7 @@ This means that arithmetic operators can be overridden for user-defined types.
29002901
The default meaning of the operators on standard types is given here.
29012902

29022903
* `+`
2903-
: Addition and vector/string concatenation.
2904+
: Addition and array/string concatenation.
29042905
Calls the `add` method on the `std::ops::Add` trait.
29052906
* `-`
29062907
: Subtraction.
@@ -3203,7 +3204,7 @@ for_expr : "for" pat "in" no_struct_literal_expr '{' block '}' ;
32033204
A `for` expression is a syntactic construct for looping over elements
32043205
provided by an implementation of `std::iter::Iterator`.
32053206

3206-
An example of a for loop over the contents of a vector:
3207+
An example of a for loop over the contents of an array:
32073208

32083209
~~~~
32093210
# type Foo = int;
@@ -3261,7 +3262,7 @@ match_pat : pat [ '|' pat ] * [ "if" expr ] ? ;
32613262

32623263
A `match` expression branches on a *pattern*. The exact form of matching that
32633264
occurs depends on the pattern. Patterns consist of some combination of
3264-
literals, destructured vectors or enum constructors, structures and
3265+
literals, destructured arrays or enum constructors, structures and
32653266
tuples, variable binding specifications, wildcards (`..`), and placeholders
32663267
(`_`). A `match` expression has a *head expression*, which is the value to
32673268
compare to the patterns. The type of the patterns must equal the type of the
@@ -3290,11 +3291,11 @@ between `_` and `..` is that the pattern `C(_)` is only type-correct if `C` has
32903291
exactly one argument, while the pattern `C(..)` is type-correct for any enum
32913292
variant `C`, regardless of how many arguments `C` has.
32923293

3293-
Used inside a vector pattern, `..` stands for any number of elements, when the
3294+
Used inside a array pattern, `..` stands for any number of elements, when the
32943295
`advanced_slice_patterns` feature gate is turned on. This wildcard can be used
3295-
at most once for a given vector, which implies that it cannot be used to
3296+
at most once for a given array, which implies that it cannot be used to
32963297
specifically match elements that are at an unknown distance from both ends of a
3297-
vector, like `[.., 42, ..]`. If followed by a variable name, it will bind the
3298+
array, like `[.., 42, ..]`. If followed by a variable name, it will bind the
32983299
corresponding slice to the variable. Example:
32993300

33003301
~~~~
@@ -3427,7 +3428,7 @@ let message = match x {
34273428
~~~~
34283429

34293430
Range patterns only work on scalar types
3430-
(like integers and characters; not like vectors and structs, which have sub-components).
3431+
(like integers and characters; not like arrays and structs, which have sub-components).
34313432
A range pattern may not be a sub-range of another range pattern inside the same `match`.
34323433

34333434
Finally, match patterns can accept *pattern guards* to further refine the
@@ -3535,10 +3536,10 @@ http://www.unicode.org/glossary/#unicode_scalar_value)
35353536
(ie. a code point that is not a surrogate),
35363537
represented as a 32-bit unsigned word in the 0x0000 to 0xD7FF
35373538
or 0xE000 to 0x10FFFF range.
3538-
A `[char]` vector is effectively an UCS-4 / UTF-32 string.
3539+
A `[char]` array is effectively an UCS-4 / UTF-32 string.
35393540

35403541
A value of type `str` is a Unicode string,
3541-
represented as a vector of 8-bit unsigned bytes holding a sequence of UTF-8 codepoints.
3542+
represented as a array of 8-bit unsigned bytes holding a sequence of UTF-8 codepoints.
35423543
Since `str` is of unknown size, it is not a _first class_ type,
35433544
but can only be instantiated through a pointer type,
35443545
such as `&str` or `String`.
@@ -3649,7 +3650,7 @@ Such recursion has restrictions:
36493650

36503651
* Recursive types must include a nominal type in the recursion
36513652
(not mere [type definitions](#type-definitions),
3652-
or other structural types such as [vectors](#vector-types) or [tuples](#tuple-types)).
3653+
or other structural types such as [arrays](#vector,-array,-and-slice-types) or [tuples](#tuple-types)).
36533654
* A recursive `enum` item must have at least one non-recursive constructor
36543655
(in order to give the recursion a basis case).
36553656
* The size of a recursive type must be finite;
@@ -4153,7 +4154,7 @@ heap data.
41534154
### Built in types
41544155

41554156
The runtime provides C and Rust code to assist with various built-in types,
4156-
such as vectors, strings, and the low level communication system (ports,
4157+
such as arrays, strings, and the low level communication system (ports,
41574158
channels, tasks).
41584159

41594160
Support for other built-in types such as simple types, tuples and

0 commit comments

Comments
 (0)