crayon
crayon copied to clipboard
Simplify PartialEq trait in HashValue
I have a pretty similar layout to your resource management in my system and also have a struct like your HashValue. However, I think you can simplify a few traits on it. Currently, you have multiple PartialEq implementation. This can be simplified to
impl<T, U> PartialEq<HashValue<U>> for HashValue<T>
where
T: PartialEq<U> + ?Sized,
U: ?Sized,
{
fn eq(&self, other: &HashValue<U>) -> bool {
self.0.eq(&other.0)
}
}
impl<T> Eq for HashValue<T> where T: PartialEq + ?Sized {}
Thanks! It does make sense to me, and I'll try to simplify it with your approach. Besides that, the codes of res module seems too ugly to understand and maintain, some code refactors is also in planning.