Skip to content

Commit 7d16726

Browse files
committed
Fix more docs
1 parent 053f681 commit 7d16726

File tree

1 file changed

+8
-6
lines changed
  • src/tools/rust-analyzer/docs/book/src/contributing

1 file changed

+8
-6
lines changed

src/tools/rust-analyzer/docs/book/src/contributing/style.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ In this case, we'll probably ask you to split API changes into a separate PR.
4949
Changes of the third group should be pretty rare, so we don't specify any specific process for them.
5050
That said, adding an innocent-looking `pub use` is a very simple way to break encapsulation, keep an eye on it!
5151

52-
Note: if you enjoyed this abstract hand-waving about boundaries, you might appreciate
53-
https://www.tedinski.com/2018/02/06/system-boundaries.html
52+
Note: if you enjoyed this abstract hand-waving about boundaries, you might appreciate [this post](https://www.tedinski.com/2018/02/06/system-boundaries.html).
53+
5454

5555
## Crates.io Dependencies
5656

@@ -231,7 +231,7 @@ fn is_string_literal(s: &str) -> bool {
231231
}
232232
```
233233

234-
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 "Bad" version, the precondition that `1` and `s.len() - 1` are valid string literal boundaries is checked in `is_string_literal` but used in `main`.
235235
In the "Good" version, the precondition check and usage are checked in the same block, and then encoded in the types.
236236

237237
**Rationale:** non-local code properties degrade under change.
@@ -271,6 +271,8 @@ fn f() {
271271
}
272272
```
273273

274+
See also [this post](https://matklad.github.io/2023/11/15/push-ifs-up-and-fors-down.html)
275+
274276
## Assertions
275277

276278
Assert liberally.
@@ -608,15 +610,15 @@ Avoid making a lot of code type parametric, *especially* on the boundaries betwe
608610

609611
```rust
610612
// GOOD
611-
fn frobnicate(f: impl FnMut()) {
613+
fn frobnicate(mut f: impl FnMut()) {
612614
frobnicate_impl(&mut f)
613615
}
614616
fn frobnicate_impl(f: &mut dyn FnMut()) {
615617
// lots of code
616618
}
617619

618620
// BAD
619-
fn frobnicate(f: impl FnMut()) {
621+
fn frobnicate(mut f: impl FnMut()) {
620622
// lots of code
621623
}
622624
```
@@ -975,7 +977,7 @@ Don't use the `ref` keyword.
975977
**Rationale:** consistency & simplicity.
976978
`ref` was required before [match ergonomics](https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md).
977979
Today, it is redundant.
978-
Between `ref` and mach ergonomics, the latter is more ergonomic in most cases, and is simpler (does not require a keyword).
980+
Between `ref` and match ergonomics, the latter is more ergonomic in most cases, and is simpler (does not require a keyword).
979981

980982
## Empty Match Arms
981983

0 commit comments

Comments
 (0)