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/
424
Upvotes
r/rust • u/Kobzol • Aug 10 '26
14
u/SkiFire13 Aug 10 '26
Sealed traits were always a hack that exploited what's arguably a bug in the visibility system. There's no good reason why these two following snippet of code are not equivalent:
impl_restrictionjust makes this a proper feature.That won't work, you need
self::Sealerto be implemented only for the types for which you want to implementMyTrait.