Skip to content

Commit ba36ec9

Browse files
committed
Revise text about capture precision
To the language about a capture path, this branch adds, "..., as well as any further projections performed by matching against patterns", and it links to the section on capturing and wildcard patterns. The link is a bit unobvious, since the section discusses what's not captured. The "as well as" phrasing is a bit awkward, and it's introduced after a comma. That indicates a non-restrictive clause, which this is not. The next rule talks about what place projections are. It seems that it might be better to instead extend that language than to try to fit this in here. We can say that destructuring can effect a place projection, and that seems right. Let's do that.
1 parent 5785fd1 commit ba36ec9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/types/closure.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ Async closures always capture all input arguments, regardless of whether or not
9898
## Capture precision
9999

100100
r[type.closure.capture.precision.capture-path]
101-
A *capture path* is a sequence starting with a variable from the environment followed by zero or more place projections that were applied to that variable, as well as any [further projections performed by matching against patterns][pattern-wildcards].
102-
103-
[pattern-wildcards]: type.closure.capture.precision.wildcard
101+
A *capture path* is a sequence starting with a variable from the environment followed by zero or more place projections from that variable.
104102

105103
r[type.closure.capture.precision.place-projection]
106-
A *place projection* is a [field access], [tuple index], [dereference] (and automatic dereferences), or [array or slice index] expression applied to a variable.
104+
A *place projection* is a [field access], [tuple index], [dereference] (and automatic dereferences), [array or slice index] expression, or [pattern destructuring] applied to a variable.
107105

108106
r[type.closure.capture.precision.intro]
109107
The closure borrows or moves the capture path, which may be truncated based on the rules described below.
@@ -126,6 +124,7 @@ Here the capture path is the local variable `s`, followed by a field access `.f1
126124
This closure captures an immutable borrow of `s.f1.1`.
127125

128126
[field access]: ../expressions/field-expr.md
127+
[pattern destructuring]: patterns.destructure
129128
[tuple index]: ../expressions/tuple-expr.md#tuple-indexing-expressions
130129
[dereference]: ../expressions/operator-expr.md#the-dereference-operator
131130
[array or slice index]: ../expressions/array-expr.md#array-and-slice-indexing-expressions

0 commit comments

Comments
 (0)