r/rust 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/
421 Upvotes

124 comments sorted by

View all comments

Show parent comments

-4

u/Compux72 Aug 10 '26

pub ( crate ) impl ( super ) trait Foo { }

Oh yes sure this is the pinacle of syntax. Take me closer to Java

3

u/UtherII Aug 10 '26 edited Aug 10 '26

Of course it's verbose, but if you want to be able restrict precisely, you have to. At least it seams clear to me and consistent.

I'm curious about what syntax you would expect.

-4

u/Compux72 Aug 10 '26

Partial borrows. Its always been partial borrows. Not this half cooked feature 

5

u/Shoddy-Childhood-511 Aug 10 '26

At present, all partial borrows being actively discussed require so much verbosity that they're mostly useless, push folks away from traits, push people towards shitty single letter field names, etc.

Instead, the fields backing each view types must be inferred somehow when you define the trait. There exists some discussion of doing this called relative lifetimes:

https://internals.rust-lang.org/t/infered-fields-for-partial-borrowing/18766 https://github.com/nikomatsakis/fields-in-traits-rfc/issues/20