You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With cmp/ops reform, all of the comparison traits allow the types of the two sides to differ. However, the traits provide a default type for the right-hand size that is the same as the left-hand side. Thus, an impl like:
impl<T:PartialEq>PartialEqforRc<T>{ ... }
is more limited than it needs to be; it could instead be
I don't think we need to do this prior to stabilization, since we can always safely generalize in the future. I'd also like to put some thought into how general we want to make things, but the example above seems like a good minimum.
@steveklabnik No, this hasn't been done yet. Basically it would require a sweep through all existing impls to generalize them.
I'm not sure where you want to track tickets like this. It's generally backwards compatible to make these changes, and not exactly high priority, but something nice for expressiveness and consistency (and definitely does not require an RFC).
@rust-lang/lang How realistic would it be to for a solution for the problem here to be designed and accepted any time soon? Ideally we'd make Some("1".to_string()) == Some("1") work, but right now we can't do that without breaking Some(1) == None and None == Some(1).
Note that it wouldn't need to have T = U and U = T defaults on the PartialEq impl. Default of T = ! and U = ! (or some other dummy type) would also work, as long as ! implements PartialEq<T> for all T, and all T implement PartialEq<!> (which overlap, but that should be fine for !).
In whatever case, is there an RFC aimed at enabling point-to-point vector comparisons (or even more general comparisons such as functional point-to-point comparisons, etc.)?
Activity
aturon commentedon Dec 20, 2014
cc @japaric @alexcrichton
I don't think we need to do this prior to stabilization, since we can always safely generalize in the future. I'd also like to put some thought into how general we want to make things, but the example above seems like a good minimum.
aturon commentedon Dec 20, 2014
A bit of follow up: I'm seeing some cases where e.g. the
PartialEqimplementation has been generalized like the above, but theEqhasn't.rollup merge of rust-lang#20065: aturon/stab-2-cmp
steveklabnik commentedon Jan 21, 2015
What's the status of this with #20065 merged?
steveklabnik commentedon Feb 15, 2015
I am guessing the status is that it's done, so I'm giving it a close. Let me know if there's anything specific still missing.
aturon commentedon Feb 16, 2015
@steveklabnik No, this hasn't been done yet. Basically it would require a sweep through all existing impls to generalize them.
I'm not sure where you want to track tickets like this. It's generally backwards compatible to make these changes, and not exactly high priority, but something nice for expressiveness and consistency (and definitely does not require an RFC).
steveklabnik commentedon Feb 16, 2015
Yeah, it's hard because it's not directly actionable, it's more like 'double check all these things.' It'd be nice if we had an actual list.
10 remaining items
m-ou-se commentedon Jan 5, 2022
@rust-lang/lang How realistic would it be to for a solution for the problem here to be designed and accepted any time soon? Ideally we'd make
Some("1".to_string()) == Some("1")work, but right now we can't do that without breakingSome(1) == NoneandNone == Some(1).m-ou-se commentedon Jan 5, 2022
Note that it wouldn't need to have
T = UandU = Tdefaults on the PartialEq impl. Default ofT = !andU = !(or some other dummy type) would also work, as long as!implementsPartialEq<T>for allT, and allTimplementPartialEq<!>(which overlap, but that should be fine for!).fdecode commentedon Nov 22, 2024
Some languages are able to do point-to-point vectorial comparisons:
Such overloading would be possible, for example, if trait
PartialOrdhad associated output type, as (this is only a sketchy suggestion):In whatever case, is there an RFC aimed at enabling point-to-point vector comparisons (or even more general comparisons such as functional point-to-point comparisons, etc.)?
scottmcm commentedon Nov 24, 2024
@fdecode That's https://doc.rust-lang.org/std/simd/cmp/trait.SimdPartialOrd.html#tymethod.simd_le
Merge pull request rust-lang#20063 from lnicola/sync-from-rust
Merge pull request rust-lang#20063 from lnicola/sync-from-rust