Snapshot of chapter 10

This commit is contained in:
Carol (Nichols || Goulding) 2021-11-14 22:06:18 -05:00
parent 1b87460130
commit 3c2ca8528c
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
2 changed files with 2047 additions and 5 deletions

2042
nostarch/chapter10.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -411,11 +411,11 @@ By using a trait bound with an `impl` block that uses generic type parameters,
we can implement methods conditionally for types that implement the specified
traits. For example, the type `Pair<T>` in Listing 10-16 always implements the
`new` function to return a new instance of `Pair<T>` (recall from the
[”Defining Methods”][methods] section of Chapter 5 that `Self` is a type alias
for the type of the `impl` block, which in this case is `Pair<T>`). But in the
next `impl` block, `Pair<T>` only implements the `cmp_display` method if its
inner type `T` implements the `PartialOrd` trait that enables comparison *and*
the `Display` trait that enables printing.
[”Defining Methods”][methods]<!-- ignore --> section of Chapter 5 that `Self`
is a type alias for the type of the `impl` block, which in this case is
`Pair<T>`). But in the next `impl` block, `Pair<T>` only implements the
`cmp_display` method if its inner type `T` implements the `PartialOrd` trait
that enables comparison *and* the `Display` trait that enables printing.
<span class="filename">Filename: src/lib.rs</span>