5 ms·
Is the purpose of encapsulation to wrap all data fields in functions offering mutable references to data? I thought it was the exact opposite.
by fnord123 9y ago
Is the purpose of encapsulation to wrap all data fields in functions offering mutable references to data? I thought it was the exact opposite.
- rom1v 9y agoThe purpose was to show that something lifetime-bound to a part of a struct becomes lifetime-bound to the whole struct when returned from a function. Using mutable references is the minimal way to get this.