Skip to content

Commit 0e735f9

Browse files
Centrilmatthewjasper
authored andcommitted
Apply suggestions from code review
Style and grammar fixes Co-Authored-By: matthewjasper <[email protected]>
1 parent 79fcc6e commit 0e735f9

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/destructors.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Destructors
22

3-
When an [initialized]&#32;[variable] or [temporary] in Rust goes out of
3+
When an [initialized]&#32;[variable] or [temporary] goes out of
44
[scope](#drop-scopes) its *destructor* is run, or it is *dropped*. [Assignment]
55
also runs the destructor of its left-hand operand, if it's initialized. If a
66
variable has been partially initialized, only its initialized fields are
77
dropped.
88

9-
The destructor of a type `T` consists of
9+
The destructor of a type `T` consists of:
1010

1111
1. If `T: Drop`, calling [`<T as std::ops::Drop>::drop`]
1212
2. Recursively running the destructor of all of its fields.
@@ -41,7 +41,7 @@ let tuple = (ShowOnDrop("Tuple first"), ShowOnDrop("Tuple second"));
4141
let moved;
4242
// No destructor run on assignment.
4343
moved = ShowOnDrop("Drops when moved");
44-
// drops now, but is then uninitialized
44+
// Drops now, but is then uninitialized.
4545
moved;
4646

4747
// Uninitialized does not drop.
@@ -60,7 +60,7 @@ Each variable or temporary is associated to a *drop scope*. When control flow
6060
leaves a drop scope all variables associated to that scope are dropped in
6161
reverse order of declaration (for variables) or creation (for temporaries).
6262

63-
Drop scopes are determined after replacing [`for`], [`if let`] and
63+
Drop scopes are determined after replacing [`for`], [`if let`], and
6464
[`while let`] expressions with the equivalent expressions using [`match`].
6565
Overloaded operators are not distinguished from built-in operators and [binding
6666
modes] are not considered.
@@ -87,17 +87,17 @@ from the inside outwards.
8787
* The parent of a statement scope is the scope of the block that contains the
8888
statement.
8989
* The parent of the expression for a `match` guard is the scope of the arm that
90-
it's for.
90+
the guard is for.
9191
* The parent of the expression for a given `match` arm is that arm's scope.
92-
* The parent of the arm scope is the scope of the match expression that it
92+
* The parent of the arm scope is the scope of the `match` expression that it
9393
belongs to.
9494
* The parent of all other scopes is the scope of the immediately enclosing
9595
expression.
9696

9797
### Scopes of function parameters
9898

9999
All function parameters are in the scope of the entire function body, so are
100-
dropped last when evaluating the function. The actual function parameter is
100+
dropped last when evaluating the function. Actual function parameters are
101101
dropped after any named parameters that are bound to parts of it.
102102

103103
```rust
@@ -124,7 +124,7 @@ patterns_in_parameters(
124124

125125
Local variables declared in a `let` statement are associated to the scope of
126126
the block that contains the `let` statement. Local variables declared in a
127-
match are associated to the arm scope of the `match` arm that they are declared
127+
`match` expression are associated to the arm scope of the `match` arm that they are declared
128128
in.
129129

130130
```rust
@@ -141,7 +141,7 @@ let declared_first = ShowOnDrop("Dropped last in outer scope");
141141
let declared_last = ShowOnDrop("Dropped first in outer scope");
142142
```
143143

144-
If multiple patterns are used in the same arm for a match, then an unspecified
144+
If multiple patterns are used in the same arm for a `match` expression, then an unspecified
145145
pattern will be used to determine the drop order.
146146

147147
### Temporary scopes
@@ -256,7 +256,7 @@ let x = &mut 0;
256256
println!("{}", x);
257257
```
258258

259-
If a borrow, dereference, field or tuple indexing expression has an extended
259+
If a borrow, dereference, field, or tuple indexing expression has an extended
260260
temporary scope then so does its operand. If an indexing expression has an
261261
extended temporary scope then the indexed expression also has an extended
262262
temporary scope.
@@ -267,7 +267,7 @@ An *extending pattern* is either
267267

268268
* An [identifier pattern] that binds by reference or mutable reference.
269269
* A [struct][struct pattern], [tuple][tuple pattern], [tuple struct][tuple
270-
struct pattern] or [slice][slice pattern] pattern where at least one of the
270+
struct pattern], or [slice][slice pattern] pattern where at least one of the
271271
direct subpatterns is a extending pattern.
272272

273273
So `ref x`, `V(ref x)` and `[ref x, y]` are all extending patterns, but `x`,
@@ -282,13 +282,13 @@ For a let statement with an initializer, an *extending expression* is an
282282
expression which is one of the following:
283283

284284
* The initializer expression.
285-
* The operand of a extending [borrow expression].
285+
* The operand of an extending [borrow expression].
286286
* The operand(s) of an extending [array][array expression], [cast][cast
287-
expression], [braced struct][struct expression] or [tuple][tuple expression]
287+
expression], [braced struct][struct expression], or [tuple][tuple expression]
288288
expression.
289289
* The final expression of any extending [block expression][block expressions].
290290

291-
So the borrow expressions in `&mut 0`, `(&1, &mut 2)` and `Some { 0: &mut 3 }`
291+
So the borrow expressions in `&mut 0`, `(&1, &mut 2)`, and `Some { 0: &mut 3 }`
292292
are all extending expressions, while the borrows in `&0 + &1` and
293293
`Some(&mut 0)` are not.
294294

@@ -320,7 +320,7 @@ Here are some examples where expressions don't have extended temporary scopes:
320320
# fn temp() {}
321321
# trait Use { fn use_temp(&self) -> &Self { self } }
322322
# impl Use for () {}
323-
// The temporary that stores the result of `temp()` lives only lives until the
323+
// The temporary that stores the result of `temp()` only lives until the
324324
// end of the let statement in these cases.
325325
326326
let x = Some(&temp()); // ERROR

0 commit comments

Comments
 (0)