@@ -112,13 +112,14 @@ field directly, which could cause the `average` field to get out of sync. The
112
112
external code to read the ` average ` but not modify it.
113
113
114
114
Because we've encapsulated the implementation details of ` AveragedCollection ` ,
115
- we can easily change aspects like the data structure in the future; for
116
- instance, we could use a ` HashSet ` instead of a ` Vec ` for the ` list ` variable.
117
- As long as the signatures of the ` add ` , ` remove ` , and ` average ` public methods
115
+ we can easily change aspects like the data structure in the future. For
116
+ instance, we could use a ` HashSet ` instead of a ` Vec ` for the ` list ` field. As
117
+ long as the signatures of the ` add ` , ` remove ` , and ` average ` public methods
118
118
stay the same, code using ` AveragedCollection ` wouldn't need to change. This
119
- wouldn't necessarily be the case if we exposed ` list ` to external code: ` HashSet `
120
- and ` Vec ` have different methods for adding and removing items, so the external
121
- code would likely have to change if it was modifying ` list ` directly.
119
+ wouldn't necessarily be the case if we exposed ` list ` to external code:
120
+ ` HashSet ` and ` Vec ` have different methods for adding and removing items, so
121
+ the external code would likely have to change if it was modifying ` list `
122
+ directly.
122
123
123
124
If encapsulation is a required aspect for a language to be considered
124
125
object-oriented, then Rust meets that requirement. Using ` pub ` or not for
0 commit comments