What is field mutability at the language level in Rust?


In The Rust Programming Language, it writes:

Rust does not support field mutability at the language level, so you cannot write something like this:

struct Point {
    mut x: i32,
    y: i32,

So :

  • which level is Rust’s field-mutability landing on?

  • And could you please explain field-mutability at language level with other language which supports it on language level? ( with some code wil be better)


Rust’s field-mutability is at library level with for example RefCell.


Thank you, I get it.


I think what is meant is you can’t specify mutability on a field-by-field basis like some other languages (e.g. ‘final’ in Java, “readonly” in C#). Instead, in Rust, you either have a mutable or immutable binding to an entire struct - so all fields are mutable or none, depending on the binding and not the field declarations of the struct.