Is it possible to avoid "conflicting implementations of trait"?

Is it possible to avoid "conflicting implementations of trait" somehow? Nightly features?

#[derive( Debug, Eq, Hash, Clone, Copy )]
pub struct Nothing
{
}

//

impl< T > PartialEq< T >
for Nothing
{
  fn eq( &self, other : T ) -> bool
  {
    false
  }
}

//

impl PartialEq< Nothing >
for Nothing
{
  fn eq( &self, other : Nothing ) -> bool
  {
    true
  }
}

Playground is here.

You could do it with nightly "specialization", or if you can restrict yourself to 'static types you could do something like this post:

https://users.rust-lang.org/t/function-comparing-2-variables-of-any-type/65668/2

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.