From the point of view of abomonation's core semantics, there is nothing wrong with providing implementations of the Abomonation trait for both a type T and a reference to it &T. Basically, the implementation for &T works exactly like that of Box<T> in abomonation's current master branch.
Such implementations would be useful for high-level users of Abomonation, who stick with derives, encode, decode and measure, because they would allow safely auto-deriving Abomonation for more types. Something which, as a matter of fact, I ended up wanting for my project.
However, and that's the reason why I'm opening this issue before submitting my changes as a PR, there is also a significant ergonomic cost to doing so for any low-level user of Abomonation who calls into the trait directly.
If Abomonation is implemented for both T and &T, then anyone who uses the Abomonation trait directly instead of going through encode, decode and measure must be super-careful, because method call syntax of the x.extent() kind becomes a deadly trap that can very easily trigger the wrong Abomonation impl through auto-Deref magic.
Instead, one must get into the habit of only calling Abomonation trait method via U::extent(&x) syntax, or if type U is unknown go for the somewhat less safe compromise of Abomonation::extent(&x).
Is this a trade-off that we can tolerate for the sake of having more Abomonation impls?
From the point of view of abomonation's core semantics, there is nothing wrong with providing implementations of the
Abomonationtrait for both a typeTand a reference to it&T. Basically, the implementation for&Tworks exactly like that ofBox<T>in abomonation's current master branch.Such implementations would be useful for high-level users of
Abomonation, who stick with derives,encode,decodeandmeasure, because they would allow safely auto-derivingAbomonationfor more types. Something which, as a matter of fact, I ended up wanting for my project.However, and that's the reason why I'm opening this issue before submitting my changes as a PR, there is also a significant ergonomic cost to doing so for any low-level user of
Abomonationwho calls into the trait directly.If
Abomonationis implemented for bothTand&T, then anyone who uses theAbomonationtrait directly instead of going throughencode,decodeandmeasuremust be super-careful, because method call syntax of thex.extent()kind becomes a deadly trap that can very easily trigger the wrongAbomonationimpl through auto-Derefmagic.Instead, one must get into the habit of only calling
Abomonationtrait method viaU::extent(&x)syntax, or if type U is unknown go for the somewhat less safe compromise ofAbomonation::extent(&x).Is this a trade-off that we can tolerate for the sake of having more
Abomonationimpls?