Skip to content

Commit

Permalink
Merge pull request #3892 from rust-lang/chriskrycho/ch-17-compilation…
Browse files Browse the repository at this point in the history
…-clarification

Ch. 17: clarify 'in order to compile'
  • Loading branch information
chriskrycho authored Apr 17, 2024
2 parents d6adb1e + 2320e43 commit efb99cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ch17-01-what-is-oo.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ Because we’ve 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` wouldn’t need to change. If we made `list` public instead,
this wouldn’t 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` wouldn’t need to change in order to compile. If we made
`list` public instead, this wouldn’t 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
Expand Down

0 comments on commit efb99cd

Please sign in to comment.