On 5/26/14 2:44 PM, Simon Sapin wrote:
Unlike C++, Rust does not have method overloading so the accessors are
much more verbose.
`nscoord ISize(WritingMode aWritingMode) const` overloaded with
`nscoord& ISize(WritingMode aWritingMode)` becomes
`get_i_size(&self, mode: WritingMode) -> T` and
`set_i_size(&mut self, mode: WritingMode, T)`.
The setter could be replaced with
`i_size_ref(&'a mut self, mode: WritingMode) -> &'a mut T`, but the
getter would still be needed so that reading does not require `&mut`. Or
perhaps we should have all three.

Is there a better way to do accessors in Rust?

Do we need the `get_` prefix? That is, could it just be `.isize()`?

(In general, I find that single-letter abbreviations read better when squished up next to the word they go with, without underscores. Just personal preference, I guess.)

Patrick

_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to