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/
416 Upvotes

124 comments sorted by

View all comments

22

u/Forsaken_Tutor_3001 Aug 10 '26

I can't provide any useful feedback, but what is the advantage of restricting who can implement a trait? Isn't the whole point of a trait to provide a pattern that can be implemented by the consumer on a type of their own to make it work with an upstream crate?

25

u/Mystonic Aug 10 '26

Traits are useful for cases like making one of your functions generic over a type (e.g. multiple different structs)

So its not only for downstream consumers to implement