Skip to content

Commit 5e826a0

Browse files
committed
fix capitalization inconsistincies in code comments
1 parent 452d9d0 commit 5e826a0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

text/3637-guard-patterns.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ For example, imagine that you're writing a function that decides whether a user
2323
```rust
2424
match user.subscription_plan() {
2525
Plan::Regular if user.credit() >= 100 => {
26-
// complete the transaction
26+
// Complete the transaction.
2727
}
2828
Plan::Premium if user.credit() >= 80 => {
29-
// complete the transaction
29+
// Complete the transaction.
3030
}
3131
_ => {
32-
// the user doesn't have enough credit, return an error message
32+
// The user doesn't have enough credit, return an error message.
3333
}
3434
}
3535
```
@@ -39,10 +39,10 @@ But this isn't great, because two of the match arms have exactly the same body.
3939
```rust
4040
match user.subscription_plan() {
4141
(Plan::Regular if user.credit() >= 100) | (Plan::Premium if user.credit() >= 80) => {
42-
// complete the transaction
42+
// Complete the transaction.
4343
}
4444
_ => {
45-
// the user doesn't have enough credit, return an error message
45+
// The user doesn't have enough credit, return an error message.
4646
}
4747
}
4848
```
@@ -109,7 +109,7 @@ let x if guard(x) = foo() {}
109109
if let x if guard(x) = foo() {}
110110
while let x if guard(x) = foo() {}
111111

112-
// allowed
112+
// Allowed:
113113
let (x if guard(x)) = foo() {} // Note that this would still error after parsing, since guard patterns are always refutable.
114114
if let (x if guard(x)) = foo() {}
115115
while let (x if guard(x)) = foo() {}
@@ -181,7 +181,7 @@ Earlier it was mentioned that guards can "move outwards" up to an or-pattern wit
181181
(Ok(Ok(x if x > 0))) | (Err(Err(x if x < 0)))
182182
<=> (Ok(Ok(x) if x > 0)) | (Err(Err(x) if x < 0))
183183
<=> (Ok(Ok(x)) if x > 0) | (Err(Err(x)) if x < 0)
184-
// cannot move outwards any further, because the conditions are different
184+
// Cannot move outwards any further, because the conditions are different.
185185
```
186186

187187
In most situations, it is preferable to have the guard as far outwards as possible; that is, at the top-level of the whole pattern or immediately within one alternative of an or-pattern.
@@ -207,9 +207,9 @@ match order {
207207
payment: Payment::Cash(amount) if amount.in_usd() > 100,
208208

209209
item_type: ItemType::A,
210-
// a bunch of other conditions...
210+
// A bunch of other conditions...
211211
} => { /* ... */ }
212-
// other similar branches...
212+
// Other similar branches...
213213
}
214214
```
215215

@@ -222,9 +222,9 @@ match order {
222222
customer,
223223
payment: Payment::Cash(amount),
224224
item_type: ItemType::A,
225-
// a bunch of other conditions...
225+
// A bunch of other conditions...
226226
} if customer.subscription_plan() == Plan::Premium && amount.in_usd() > 100 => { /* ... */ }
227-
// other similar branches...
227+
// Other similar branches...
228228
}
229229
```
230230

0 commit comments

Comments
 (0)