Skip to content

Commit e381b44

Browse files
committed
explain scrutinee in glossary.
1 parent 29638c5 commit e381b44

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

src/expressions/loop-expr.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ while i < 10 {
7070
> &nbsp;&nbsp; `while` `let` [_Pattern_] `=` [_Expression_]<sub>except struct expression</sub>
7171
> [_BlockExpression_]
7272
73+
[scrutinee]: glossary.html#scrutinee
74+
7375
A `while let` loop is semantically similar to a `while` loop but in place of a
7476
condition expression it expects the keyword `let` followed by a refutable
75-
pattern, an `=`, a scrutinee expression and a block expression. If the value of
77+
pattern, an `=`, a [scrutinee] expression and a block expression. If the value of
7678
the expression on the right hand side of the `=` matches the pattern, the loop
7779
body block executes then control returns to the pattern matching statement.
7880
Otherwise, the while expression completes.

src/expressions/match-expr.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
> _MatchArmGuard_ :\
2424
> &nbsp;&nbsp; `if` [_Expression_]
2525
26+
[scrutinee]: glossary.html#scrutinee
27+
2628
A *`match` expression* branches on a pattern. The exact form of matching that
2729
occurs depends on the [pattern]. A `match`
28-
expression has a *scrutinee expression*, which is the value to compare to the
30+
expression has a *[scrutinee] expression*, which is the value to compare to the
2931
patterns. The scrutinee expression and the patterns must have the same type.
3032

3133
A `match` behaves differently depending on whether or not the scrutinee

src/expressions/struct-expr.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ let base = Point3d {x: 1, y: 2, z: 3};
7171
Point3d {y: 0, z: 10, .. base};
7272
```
7373

74+
[scrutinee]: glossary.html#scrutinee
75+
7476
Struct expressions with curly braces can't be used directly in a [loop] or [if]
75-
expression's head, or in the scrutinee of a [if let] or [match] expression.
77+
expression's head, or in the [scrutinee] of an [if let] or [match] expression.
7678
However, struct expressions can be in used in these situations if they are
7779
within another expression, for example inside [parentheses].
7880

src/glossary.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ Types that can be referred to by a path directly. Specifically [enums],
8080
Prelude, or The Rust Prelude, is a small collection of items - mostly traits - that are
8181
imported into every module of every crate. The traits in the prelude are pervasive.
8282

83+
### Scrutinee
84+
85+
A scrutinee is the expression that is matched on in `match` expressions and
86+
similar pattern matching constructs. For example, in `match x { A => 1, B => 2 }`,
87+
the expression `x` is the scrutinee.
88+
8389
### Size
8490

8591
The size of a value has two definitions.

src/patterns.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ Patterns are used in:
6767

6868
## Destructuring
6969

70+
[scrutinee]: glossary.html#scrutinee
71+
7072
Patterns can be used to *destructure* [structs], [enums], and [tuples].
7173
Destructuring breaks up a value into its component pieces. The syntax used is
72-
almost the same as when creating such values. In a pattern whose scrutinee
74+
almost the same as when creating such values. In a pattern whose [scrutinee]
7375
expression has a `struct`, `enum` or `tuple` type, a placeholder (`_`) stands
7476
in for a *single* data field, whereas a wildcard `..` stands in for *all* the
7577
remaining fields of a particular variant. When destructuring a data structure

0 commit comments

Comments
 (0)