by _nalply · 3y ago · 0 comments
I wanted to separate the type, the trait and the implementation of the trait in different crates. I was forced to use newtypes but newtypes need a lot of boiler plate. It was painful.
In my opinion this is a larger barrier than having separate Cargo.toml files.
I usually put the traits in a separate crate, but keep concrete types and implementations for them in the same crate.
What is the use-case for splitting a type and it's implementation into separate crates? (except for cases where the trait or the type are out of your control, then one indeed needs to use the new-type escape hatch)
The problem was that the trait implementations of the types was something like not a core task of the types themselves.