Skip to content

Commit fb09639

Browse files
committed
Rollup merge of #28889 - JIghtuse:str_doc, r=steveklabnik
2 parents c66ff93 + 1e0fbbd commit fb09639

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/doc/trpl/iterators.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ loop is just a handy way to write this `loop`/`match`/`break` construct.
4242
`for` loops aren't the only thing that uses iterators, however. Writing your
4343
own iterator involves implementing the `Iterator` trait. While doing that is
4444
outside of the scope of this guide, Rust provides a number of useful iterators
45-
to accomplish various tasks. Before we talk about those, we should talk about a
46-
Rust anti-pattern. And that's using ranges like this.
45+
to accomplish various tasks. But first, a few notes about limitations of ranges.
4746

48-
Yes, we just talked about how ranges are cool. But ranges are also very
49-
primitive. For example, if you needed to iterate over the contents of a vector,
50-
you may be tempted to write this:
47+
Ranges are very primitive, and we often can use better alternatives. Consider
48+
following Rust anti-pattern: using ranges to emulate a C-style `for` loop. Let’s
49+
suppose you needed to iterate over the contents of a vector. You may be tempted
50+
to write this:
5151

5252
```rust
5353
let nums = vec![1, 2, 3];
@@ -281,8 +281,8 @@ If you are trying to execute a closure on an iterator for its side effects,
281281
just use `for` instead.
282282

283283
There are tons of interesting iterator adapters. `take(n)` will return an
284-
iterator over the next `n` elements of the original iterator. Let's try it out with our infinite
285-
iterator from before:
284+
iterator over the next `n` elements of the original iterator. Let's try it out
285+
with an infinite iterator:
286286

287287
```rust
288288
for i in (1..).take(5) {

src/doc/trpl/lifetimes.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ With that in mind, let’s learn about lifetimes.
4343
Lending out a reference to a resource that someone else owns can be
4444
complicated. For example, imagine this set of operations:
4545

46-
- I acquire a handle to some kind of resource.
47-
- I lend you a reference to the resource.
48-
- I decide I’m done with the resource, and deallocate it, while you still have
46+
1. I acquire a handle to some kind of resource.
47+
2. I lend you a reference to the resource.
48+
3. I decide I’m done with the resource, and deallocate it, while you still have
4949
your reference.
50-
- You decide to use the resource.
50+
4. You decide to use the resource.
5151

5252
Uh oh! Your reference is pointing to an invalid resource. This is called a
5353
dangling pointer or ‘use after free’, when the resource is memory.

0 commit comments

Comments
 (0)