Merge pull request #3892 from rust-lang/chriskrycho/ch-17-compilation-clarification

Ch. 17: clarify 'in order to compile'
This commit is contained in:
Chris Krycho 2024-04-17 16:15:52 -06:00 committed by GitHub
commit efb99cdcae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -86,10 +86,10 @@ Because weve encapsulated the implementation details of the struct
in the future. For instance, we could use a `HashSet<i32>` instead of a
`Vec<i32>` for the `list` field. As long as the signatures of the `add`,
`remove`, and `average` public methods stay the same, code using
`AveragedCollection` wouldnt need to change. If we made `list` public instead,
this wouldnt necessarily be the case: `HashSet<i32>` and `Vec<i32>` have
different methods for adding and removing items, so the external code would
likely have to change if it were modifying `list` directly.
`AveragedCollection` wouldnt need to change in order to compile. If we made
`list` public instead, this wouldnt necessarily be the case: `HashSet<i32>` and
`Vec<i32>` have different methods for adding and removing items, so the external
code would likely have to change if it were modifying `list` directly.
If encapsulation is a required aspect for a language to be considered
object-oriented, then Rust meets that requirement. The option to use `pub` or