Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: merge cmp::Eq and cmp::Equiv #7088

Closed
erickt opened this issue Jun 12, 2013 · 6 comments
Closed

RFC: merge cmp::Eq and cmp::Equiv #7088

erickt opened this issue Jun 12, 2013 · 6 comments

Comments

@erickt
Copy link
Contributor

erickt commented Jun 12, 2013

Using @nikomatsakis's double dispatch overloading trick, we could merge cmp::Eq and cmp::Equiv. This would allow us to remove all the _equiv methods from HashMap.

You can find an implementation prototype here.

I mentioned this in IRC, and @pcwalton and @huonw mentioned that this could complicate type inference though, but I couldn't figure out a good case where merging the two would cause a problem.

@pnkfelix
Copy link
Member

visting for triage, email from 2013-08-26.

So, I assume that #[deriving(Eq)] struct Foo<T> { ... } (for example) would, in this new world, cause the implicit introduction of an impl like:

impl<T:Eq<T>> Eq<Foo<T>> for Foo<T> {
  fn eq(&self, other: &Foo<T>) { ... <same as now> ... }
}

Is that right?

I'm not sure about the type inference implications. (@nikomatsakis, any comments?)

(I'm also not sure that the motivation of removing the _equiv methods from HashMap is a good one; but maybe one can always re-encode any previously behavior by wrapping one's keys in structs with their own non-derived implementation of Eq, so this objection may not be well motivated. Not sure yet.)

@pnkfelix
Copy link
Member

I did spend a little while trying to see how hard it would be to hack this in. Its not something that can be done piecemeal, I don't think. At least my brief attempts to switch the lang_item over to Equiv or erickt's Eq2 did not go smoothly.

@nikomatsakis
Copy link
Contributor

I think I prefer to keep Eq as homogeneous comparisons.

@pnkfelix
Copy link
Member

so maybe we should close this? Or ask for input from the rest of the core team?

@sanxiyn
Copy link
Member

sanxiyn commented Feb 3, 2014

Nominating.

@pnkfelix
Copy link
Member

pnkfelix commented Feb 6, 2014

We're planning to keep Equiv (I thought briefly that we might drop Equiv, but it is important for servo use cases such as case-insensitive lookup in a table).

We don't think the change suggested here (see e.g. my comment above) has sufficient motivation. Use Eq for the simple monomorphic cases and Equiv for the cases when the types may differ.

Closing as wont-fix

@pnkfelix pnkfelix closed this as completed Feb 6, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 22, 2021
add type in help message of from_over_into

fixes rust-lang#7088
changelog: add type in help message of from_over_into
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants