Open taladar opened 2 years ago
= note: required because of the requirements on the impl of `Diffable<'_>` for `Vec<std::string::String>`
I don't really know this lib but looking at the trait impls we have
impl<'a, T: Same + Diffable<'a> + 'a> Diffable<'a> for Vec<T>
so T = String
needs to implement Same
and Diffable
. Same for String
is not implemented.
Not sure if there is a reason for not implementing it or if it can just be added to https://github.com/distil/diffus/blob/master/diffus/src/same.rs#L25
Indeed, Same for Vec\<u8> is probably also pretty useful in general but my ticket was mostly about the strange suggestions in the derive macro roughly in the middle of the compiler output.
Do you know if anything can be done about it in this lib? I guessed that this was just rustc trying its darndest to help out
I am not familiar enough with the writing of macros to know what exactly causes it but presumably the suggestion is propagated from some type in the generated code to that place. Something like cargo-expand might be useful to get some more information on the cause and possibly minimize the example to report it to the compiler issue tracker if necessary.
Great find @taladar !
Thought about it for a few minutes I don't see any reason for not having it as a default implementation.
str does already have a default Same using Eq, so String should too to be "least surprising"
If you need an alternative "sameness" you'll have to wrap it in it's own type.
Added a test and fixed it: https://github.com/distil/diffus/pull/105
I am trying to derive Diffus on the following data type
which gives me some strange suggestions in the error it produces (on Rust 1.57.0)
I am reasonably sure that neither &Diffus nor Box make sense in the derive macro parameters?
Changing it to &Diffus experimentally yields