mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
Improve grammar and fix code example in style guide
This commit is contained in:
parent
3f4e9914ff
commit
2233749692
1 changed files with 4 additions and 5 deletions
|
@ -197,7 +197,7 @@ fn frobnicate(walrus: Option<Walrus>) {
|
|||
}
|
||||
```
|
||||
|
||||
Avoid preconditions that spawn function boundaries:
|
||||
Avoid preconditions that span across function boundaries:
|
||||
|
||||
|
||||
```rust
|
||||
|
@ -218,9 +218,8 @@ fn foo() {
|
|||
}
|
||||
|
||||
// Not as good
|
||||
fn is_string_literal(s: &str) -> Option<&str> {
|
||||
fn is_string_literal(s: &str) -> bool {
|
||||
s.starts_with('"') && s.ends_with('"')
|
||||
Some()
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
|
@ -231,8 +230,8 @@ fn foo() {
|
|||
}
|
||||
```
|
||||
|
||||
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`.
|
||||
In the "Good" version, precondition check and usage are checked in the same block, and then encoded in the types.
|
||||
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`.
|
||||
In the "Good" version, the precondition check and usage are checked in the same block, and then encoded in the types.
|
||||
|
||||
# Early Returns
|
||||
|
||||
|
|
Loading…
Reference in a new issue