Re:Gnirehtet rewritten in Rust
by solidsnack9000 on Sunday September 24, 2017 @05:59PM
(#15326706)
> ...the first example "encapsulation" demonstrates exactly no encapsulation.
It demonstrates a kind of getter, but a weird one since it returns a mutable field. These are not the most encapsulated thing.
In general terms although sometimes you need to do things like this, shared mutable state is something you should be avoiding in any language and you should thank Rust for making it harder on you.