diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-12-13 11:05:22 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-13 11:05:22 +0900 |
| commit | 1698773263f89c9f3507eddef032f76ae065e0da (patch) | |
| tree | 9dfc1446ddd9f3e757107a6aabb0ff985865270c /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp | |
| parent | f61e5cab760e21d61d8ba3d58badb20c54ebb1c4 (diff) | |
| parent | 6edc90a3e21a786bfe1e0a6bca28e8e687064554 (diff) | |
| download | rust-1698773263f89c9f3507eddef032f76ae065e0da.tar.gz rust-1698773263f89c9f3507eddef032f76ae065e0da.zip | |
Rollup merge of #79360 - wchargin:wchargin-doc-iter-by-reference, r=m-ou-se
std::iter: document iteration over `&T` and `&mut T`
A colleague of mine is new to Rust, and mentioned that it was “slightly
confusing” to figure out what `&mut` does in iterating over `&mut foo`:
```rust
for value in &mut self.my_vec {
// ...
}
```
My colleague had read the `std::iter` docs and not found the answer
there. There is a brief section at the top about “the three forms of
iteration”, which mentions `iter_mut`, but it doesn’t cover the purpose
of `&mut coll` for a collection `coll`. This patch adds an explanatory
section to the docs. I opted to create a new section so that it can
appear after the note that `impl<I: Iterator> IntoIterator for I`, and
it’s nice for the existing “three forms of iteration” to appear near the
top.
Test Plan:
Ran `./x.py doc library/core`, and the result looked good, including
links. Manually copy-pasted the two doctests into the playground and ran
them.
wchargin-branch: doc-iter-by-reference
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
