jeikabu / nng-rust

MIT License
18 stars 8 forks source link

Implement Eq for handle types #6

Closed neachdainn closed 5 years ago

neachdainn commented 5 years ago

Closes #4

neachdainn commented 5 years ago

Maybe this isn't the correct way to do it. I thought nng_*_id returned an unsigned integer but it looks like it doesn't. Perhaps the correct implementation would be more along the lines of:

impl PartialEq for nng_socket {
    fn eq(&self, other: &Self) -> bool {
        unsafe {
            let us = nng_socket_id(self);
            let them = nng_socket_id(other);

            us == them
        }
    }
}

And at that point, it might be out of the scope of this crate... Or it might not, since this is the only crate that can implement traits for the NNG types. I'm not sure what is correct here.

neachdainn commented 5 years ago

I think I've decided that I don't like this.