Skip to content

Commit 7b23a00

Browse files
authored
Merge pull request #1951 from mlevesquedion/fix/duck-typing-typo
Add missing "of" before `"duck typing"`.
2 parents b227d5e + c19fca6 commit 7b23a00

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/ch17-02-trait-objects.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,15 @@ new type and draw it because `SelectBox` implements the `Draw` trait, which
275275
means it implements the `draw` method.
276276

277277
This concept—of being concerned only with the messages a value responds to
278-
rather than the value’s concrete type—is similar to the concept *duck typing*
279-
in dynamically typed languages: if it walks like a duck and quacks like a duck,
280-
then it must be a duck! In the implementation of `run` on `Screen` in Listing
281-
17-5, `run` doesn’t need to know what the concrete type of each component is.
282-
It doesn’t check whether a component is an instance of a `Button` or a
283-
`SelectBox`, it just calls the `draw` method on the component. By specifying
284-
`Box<dyn Draw>` as the type of the values in the `components` vector, we’ve
285-
defined `Screen` to need values that we can call the `draw` method on.
278+
rather than the value’s concrete type—is similar to the concept of *duck
279+
typing* in dynamically typed languages: if it walks like a duck and quacks
280+
like a duck, then it must be a duck! In the implementation of `run` on `Screen`
281+
in Listing 17-5, `run` doesn’t need to know what the concrete type of each
282+
component is. It doesn’t check whether a component is an instance of a `Button`
283+
or a `SelectBox`, it just calls the `draw` method on the component. By
284+
specifying `Box<dyn Draw>` as the type of the values in the `components`
285+
vector, we’ve defined `Screen` to need values that we can call the `draw`
286+
method on.
286287

287288
The advantage of using trait objects and Rust’s type system to write code
288289
similar to code using duck typing is that we never have to check whether a

0 commit comments

Comments
 (0)