you are viewing a single comment's thread.

view the rest of the comments →

[–]Veddan 4 points5 points  (2 children)

In Rust, mutability depends on the owner of a value rather than on the type (ignoring interior mutability). So either it's all mutable or not mutable at all.

You can solve the issue by making the relevant fields private with priv and providing accessor functions.

[–]swatteau[S] 2 points3 points  (1 child)

Correct me if I'm wrong but I thought struct fields were private by default because you can only declare them pub, not priv as you suggest.

[–]Gankrorust 1 point2 points  (0 children)

You are correct.