Skip to content

Commit 691f0e4

Browse files
authored
Merge pull request #4057 from rust-lang/adapter-not-adaptor-3824
Standardize on 'adapter', not 'adaptor'
2 parents f26aa3d + 52fa1c9 commit 691f0e4

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

ci/dictionary.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ personal_ws-1.1 en 0 utf-8
22
abcabcabc
33
abcd
44
abcdefghijklmnopqrstuvwxyz
5-
adaptor
6-
adaptors
75
AddAssign
86
Addr
97
adfb

src/ch13-02-iterators.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ trait. Some of these methods call the `next` method in their definition, which
111111
is why you’re required to implement the `next` method when implementing the
112112
`Iterator` trait.
113113

114-
Methods that call `next` are called *consuming adaptors*, because calling them
114+
Methods that call `next` are called *consuming adapters*, because calling them
115115
uses up the iterator. One example is the `sum` method, which takes ownership of
116116
the iterator and iterates through the items by repeatedly calling `next`, thus
117117
consuming the iterator. As it iterates through, it adds each item to a running
@@ -131,17 +131,17 @@ ownership of the iterator we call it on.
131131

132132
### Methods that Produce Other Iterators
133133

134-
*Iterator adaptors* are methods defined on the `Iterator` trait that don’t
134+
*Iterator adapters* are methods defined on the `Iterator` trait that don’t
135135
consume the iterator. Instead, they produce different iterators by changing
136136
some aspect of the original iterator.
137137

138-
Listing 13-14 shows an example of calling the iterator adaptor method `map`,
138+
Listing 13-14 shows an example of calling the iterator adapter method `map`,
139139
which takes a closure to call on each item as the items are iterated through.
140140
The `map` method returns a new iterator that produces the modified items. The
141141
closure here creates a new iterator in which each item from the vector will be
142142
incremented by 1:
143143

144-
<Listing number="13-14" file-name="src/main.rs" caption="Calling the iterator adaptor `map` to create a new iterator">
144+
<Listing number="13-14" file-name="src/main.rs" caption="Calling the iterator adapter `map` to create a new iterator">
145145

146146
```rust,not_desired_behavior
147147
{{#rustdoc_include ../listings/ch13-functional-features/listing-13-14/src/main.rs:here}}
@@ -156,7 +156,7 @@ However, this code produces a warning:
156156
```
157157

158158
The code in Listing 13-14 doesn’t do anything; the closure we’ve specified
159-
never gets called. The warning reminds us why: iterator adaptors are lazy, and
159+
never gets called. The warning reminds us why: iterator adapters are lazy, and
160160
we need to consume the iterator here.
161161

162162
To fix this warning and consume the iterator, we’ll use the `collect` method,
@@ -181,9 +181,9 @@ on each item. This is a great example of how closures let you customize some
181181
behavior while reusing the iteration behavior that the `Iterator` trait
182182
provides.
183183

184-
You can chain multiple calls to iterator adaptors to perform complex actions in
184+
You can chain multiple calls to iterator adapters to perform complex actions in
185185
a readable way. But because all iterators are lazy, you have to call one of the
186-
consuming adaptor methods to get results from calls to iterator adaptors.
186+
consuming adapter methods to get results from calls to iterator adapters.
187187

188188
### Using Closures that Capture Their Environment
189189

src/ch13-03-improving-our-io-project.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ value we want to put in the `query` field of `Config`. If `next` returns a
116116
not enough arguments were given and we return early with an `Err` value. We do
117117
the same thing for the `file_path` value.
118118

119-
### Making Code Clearer with Iterator Adaptors
119+
### Making Code Clearer with Iterator Adapters
120120

121121
We can also take advantage of iterators in the `search` function in our I/O
122122
project, which is reproduced here in Listing 13-21 as it was in Listing 12-19:
@@ -129,14 +129,14 @@ project, which is reproduced here in Listing 13-21 as it was in Listing 12-19:
129129

130130
</Listing>
131131

132-
We can write this code in a more concise way using iterator adaptor methods.
132+
We can write this code in a more concise way using iterator adapter methods.
133133
Doing so also lets us avoid having a mutable intermediate `results` vector. The
134134
functional programming style prefers to minimize the amount of mutable state to
135135
make code clearer. Removing the mutable state might enable a future enhancement
136136
to make searching happen in parallel, because we wouldn’t have to manage
137137
concurrent access to the `results` vector. Listing 13-22 shows this change:
138138

139-
<Listing number="13-22" file-name="src/lib.rs" caption="Using iterator adaptor methods in the implementation of the `search` function">
139+
<Listing number="13-22" file-name="src/lib.rs" caption="Using iterator adapter methods in the implementation of the `search` function">
140140

141141
```rust,ignore
142142
{{#rustdoc_include ../listings/ch13-functional-features/listing-13-22/src/lib.rs:here}}
@@ -146,7 +146,7 @@ concurrent access to the `results` vector. Listing 13-22 shows this change:
146146

147147
Recall that the purpose of the `search` function is to return all lines in
148148
`contents` that contain the `query`. Similar to the `filter` example in Listing
149-
13-16, this code uses the `filter` adaptor to keep only the lines that
149+
13-16, this code uses the `filter` adapter to keep only the lines that
150150
`line.contains(query)` returns `true` for. We then collect the matching lines
151151
into another vector with `collect`. Much simpler! Feel free to make the same
152152
change to use iterator methods in the `search_case_insensitive` function as
@@ -158,7 +158,7 @@ The next logical question is which style you should choose in your own code and
158158
why: the original implementation in Listing 13-21 or the version using
159159
iterators in Listing 13-22. Most Rust programmers prefer to use the iterator
160160
style. It’s a bit tougher to get the hang of at first, but once you get a feel
161-
for the various iterator adaptors and what they do, iterators can be easier to
161+
for the various iterator adapters and what they do, iterators can be easier to
162162
understand. Instead of fiddling with the various bits of looping and building
163163
new vectors, the code focuses on the high-level objective of the loop. This
164164
abstracts away some of the commonplace code so it’s easier to see the concepts

src/ch13-04-performance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ multiply the values together, sum all the results, and shift the bits in the
6565
sum `qlp_shift` bits to the right.
6666

6767
Calculations in applications like audio decoders often prioritize performance
68-
most highly. Here, we’re creating an iterator, using two adaptors, and then
68+
most highly. Here, we’re creating an iterator, using two adapters, and then
6969
consuming the value. What assembly code would this Rust code compile to? Well,
7070
as of this writing, it compiles down to the same assembly you’d write by hand.
7171
There’s no loop at all corresponding to the iteration over the values in

0 commit comments

Comments
 (0)