(no title)
kketch
|
6 months ago
Technically no. Producing side effects from a setter is not unexpected, even if it often the best idea to have a setter have a lot of unexpected side effects. However producing side effects from getters is definitely unexpected and should not be done. Interestingly it's one of the areas where rust is really useful, it forces you express your intent in terms of mutability and is able to enforce these expectations we have.
galangalalgol|6 months ago
jibal|6 months ago
eru|6 months ago
Though Rust only cares about mutability, it doesn't track whether you are going to launch the nukes or format the hard disk.
kketch|6 months ago
Rust provides safeguards and helps you to enforce mutability and ownership at the language level, but how you leverage those safeguards is still up to you.
If you really want it you can still get Rust to mutate stuff when you call a non mutable function after all. Like you could kill someone with a paper straw