External Publication
Visit Post

Yet another half-baked idea for working around the orphan rule

Rust Internals [Unofficial] March 31, 2026
Source

I can't find it right now, but I'm pretty sure I've seen a proposal here on IRLO that is similar to this, but you would indicate which traits are being impl right in the type. I guess the syntax was something like type HashedMyType = MyType impl Hash = myimpl for a variant of MyType that uses a named impl of Hash, or something like that

Anyway both proposals are equivalent to newtype pattern, only with less boilerplate. Which is great news, since the downside of the newtype pattern is the huge amounts of boilerplate

However I think that boilerplate when defining the newtype is tolerable. What really sucks is wrapping/unwrapping types when using the types. That's what prevents me from using NonZero* types for example. So I think you need to have something to offer in this front.

Also, a small comment on syntax. I think that using punctuation in Type\foo isn't a good tradeoff. That's an uncommon feature and deserves a self-explanatory contextual keyword. Maybe reusing the pattern types syntax like Type is foo would work (if foo is an identifier this builds a faceted type, if it's a pattern with literals it forms pattern type. And maybe unify both concepts under a generalization). Or something like Type facet foo

Discussion in the ATmosphere

Loading comments...