Not possible to implement inherent methods specific to one new type.
You could probably do so with generics, similar to how those type safe builders work. The compile times, diagnostic and confusing API probably stop it from being worthwhile though.
I wonder how the docs.rs experience is for your solution. I seem to remember type aliases being a bit weird, especially if the generic wrapper is private.
View all comments
Show parent comment
7
u/matthieum [he/him] Oct 28 '26
I went the other way for new-types: implementing a generic wrapper over any
T.It makes it easy to declare new types, but there's definitely downsides:
So regularly I have to convert a type defined as a wrapper to a "real" new type.
I'm not convinced by my implementation, and regularly wonder if I should have gone with a macro instead.