File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ fn frobnicate(walrus: Option<Walrus>) {
197
197
}
198
198
```
199
199
200
- Avoid preconditions that spawn function boundaries:
200
+ Avoid preconditions that span across function boundaries:
201
201
202
202
203
203
``` rust
@@ -218,9 +218,8 @@ fn foo() {
218
218
}
219
219
220
220
// Not as good
221
- fn is_string_literal (s : & str ) -> Option < & str > {
221
+ fn is_string_literal (s : & str ) -> bool {
222
222
s . starts_with ('"' ) && s . ends_with ('"' )
223
- Some ()
224
223
}
225
224
226
225
fn foo () {
@@ -231,8 +230,8 @@ fn foo() {
231
230
}
232
231
```
233
232
234
- In the "Not as good" version, the precondition that ` 1 ` is a valid char boundary is checked in ` is_string_literal ` and utilized in ` foo ` .
235
- In the "Good" version, precondition check and usage are checked in the same block, and then encoded in the types.
233
+ In the "Not as good" version, the precondition that ` 1 ` is a valid char boundary is checked in ` is_string_literal ` and used in ` foo ` .
234
+ In the "Good" version, the precondition check and usage are checked in the same block, and then encoded in the types.
236
235
237
236
# Early Returns
238
237
You can’t perform that action at this time.
0 commit comments