aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/style.md
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-01 20:36:33 +0100
committerGitHub <[email protected]>2020-10-01 20:36:33 +0100
commit505ff4070a3de962dbde66f08b6550cda2eb4eab (patch)
treea9fe9f827708ec3164d52083d15dfc59b77f229d /docs/dev/style.md
parent3f4e9914ff77c76ad3cbdebe1e4e2c0a78818d63 (diff)
parent223374969205059f3448ef9e9d7ab1c44d5fa8cf (diff)
Merge #6114
6114: Improve grammar and fix code example in style guide r=kjeremy a=lnicola Co-authored-by: LaurenČ›iu Nicola <[email protected]>
Diffstat (limited to 'docs/dev/style.md')
-rw-r--r--docs/dev/style.md9
1 files changed, 4 insertions, 5 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md
index bcd86fd3f..f0fdb5adc 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -197,7 +197,7 @@ fn frobnicate(walrus: Option<Walrus>) {
197} 197}
198``` 198```
199 199
200Avoid preconditions that spawn function boundaries: 200Avoid preconditions that span across function boundaries:
201 201
202 202
203```rust 203```rust
@@ -218,9 +218,8 @@ fn foo() {
218} 218}
219 219
220// Not as good 220// Not as good
221fn is_string_literal(s: &str) -> Option<&str> { 221fn is_string_literal(s: &str) -> bool {
222 s.starts_with('"') && s.ends_with('"') 222 s.starts_with('"') && s.ends_with('"')
223 Some()
224} 223}
225 224
226fn foo() { 225fn foo() {
@@ -231,8 +230,8 @@ fn foo() {
231} 230}
232``` 231```
233 232
234In the "Not as good" version, the precondition that `1` is a valid char boundary is checked in `is_string_literal` and utilized in `foo`. 233In the "Not as good" version, the precondition that `1` is a valid char boundary is checked in `is_string_literal` and used in `foo`.
235In the "Good" version, precondition check and usage are checked in the same block, and then encoded in the types. 234In the "Good" version, the precondition check and usage are checked in the same block, and then encoded in the types.
236 235
237# Early Returns 236# Early Returns
238 237