|
|
|
|
|
by MeetingsBrowser
84 days ago
|
|
In my experience using newtypes like this causes a constant shuffle between the original type and the newtype. If a library exposes Foo and I wrap it in MyFoo implementing some trait, I need to convert to MyFoo everywhere the trait is needed and back to Foo everywhere the original type is expected. In practice this means cluttering the code with as_foo and as_myfoo all over the place. You could also impl From or Deref for one direction of the conversion, but it makes the code less clear in my opinion. |
|
Serde also comes with a bunch of attributes and features to make it easy to short-circuit this stuff ad hoc.
I know this only solves the serialization use case, but that seems to be where most people run into this.