Add missing "of" before "duck typing".

This seems like a typo to me :
...similar to the concept      duck typing in dynamically...
...similar to the concept *of* duck typing in dynamically...
This commit is contained in:
Michaël Lévesque-Dion
2019-05-09 07:20:11 -04:00
parent a203290c64
commit c19fca6083

View File

@@ -275,14 +275,15 @@ new type and draw it because `SelectBox` implements the `Draw` trait, which
means it implements the `draw` method.
This concept—of being concerned only with the messages a value responds to
rather than the values concrete type—is similar to the concept *duck typing*
in dynamically typed languages: if it walks like a duck and quacks like a duck,
then it must be a duck! In the implementation of `run` on `Screen` in Listing
17-5, `run` doesnt need to know what the concrete type of each component is.
It doesnt check whether a component is an instance of a `Button` or a
`SelectBox`, it just calls the `draw` method on the component. By specifying
`Box<dyn Draw>` as the type of the values in the `components` vector, weve
defined `Screen` to need values that we can call the `draw` method on.
rather than the values concrete type—is similar to the concept of *duck
typing* in dynamically typed languages: if it walks like a duck and quacks
like a duck, then it must be a duck! In the implementation of `run` on `Screen`
in Listing 17-5, `run` doesnt need to know what the concrete type of each
component is. It doesnt check whether a component is an instance of a `Button`
or a `SelectBox`, it just calls the `draw` method on the component. By
specifying `Box<dyn Draw>` as the type of the values in the `components`
vector, weve defined `Screen` to need values that we can call the `draw`
method on.
The advantage of using trait objects and Rusts type system to write code
similar to code using duck typing is that we never have to check whether a