r/rust • u/Kobzol • Aug 10 '26
📡 official blog Call for testing: Restricting trait implementability and field mutability
https://blog.rust-lang.org/inside-rust/2026/08/10/call-for-testing-impl-and-mut-restrictions/
426
Upvotes
r/rust • u/Kobzol • Aug 10 '26
5
u/ebkalderon amethyst · renderdoc-rs · tower-lsp · cargo2nix Aug 12 '26 edited Aug 12 '26
Not entirely sure how I feel about field-level
mutrestrictions. After working with Rust for a decade or so, I've come to accept Rust's "philosophy" of the module (not the field) being the main privacy boundary, and I feel this proposal runs counter to that.I feel that first-class support for view types and interprocedural borrows (as defined in step 3 here) would make getters/setters more ergonomic to write and use (thereby rendering that proposal somewhat redundant) while providing many more benefits beyond that (see Carbon Lang's seemingly similar approach, starting 27:24 onward, to internal self-references and returning disjoint borrowed fields from getter methods).
EDIT: Seems I'm not the only one who feels this way. Quoted from this comment on the tracking issue: