[Pre-RFC] read-only visibility

As I said in the linked thread, I am extremely against using get/set terminology because it is actively misleading.

Also note, there is no way to specify read-only in Rust due to the existence of UnsafeCell and all things built on top of it (modulo the compiler internal Freeze auto trait). I don't think that read-only fields is the correct way to sell this feature. It is better to lean into the notion that &T is a shared reference to T, so these fields would be shareable fields.

I think a deny by default warning is good for this.

Similarly to how Rust doesn't have a notion of read only, it doesn't have a notion of write only, so it would be impossible to enforce this other than just allowing assignment. Not allowing references to these fields is not significantly better than just having a setter for these fields.


link to previous thread where I spoke about this,

3 Likes