crayon icon indicating copy to clipboard operation
crayon copied to clipboard

Simplify PartialEq trait in HashValue

Open TimDiekmann opened this issue 7 years ago • 1 comments

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 {}

TimDiekmann avatar Aug 28 '18 11:08 TimDiekmann

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.

shawnscode avatar Aug 29 '18 07:08 shawnscode