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

Implement FloatEq over standard types #3

Closed
jtempest opened this issue May 16, 2020 · 1 comment
Closed

Implement FloatEq over standard types #3

jtempest opened this issue May 16, 2020 · 1 comment

Comments

@jtempest
Copy link
Owner

jtempest commented May 16, 2020

FloatEq is currently implemented over the following types:

  • f32
  • f64
  • [T; n] where T: FloatEq
  • num::Complex<T> where T: FloatEq (behind a feature flag)

It would be helpful to expand this to be implemented over a similar range of standard container types as PartialEq is, This is a list of the potentially relevant impls, using the PartialEq Implementors list as of version 1.43.1:

Special

impl PartialEq<!> for !

Reference types (immutable)

impl<'_, '_, A, B> PartialEq<&'_ B> for &'_ A where
    A: PartialEq<B> + ?Sized,
    B: ?Sized,

TODO: The corresponsing a == &b and &a == b are missing from PartialEq because of this issue, but do we have the same restraint? EDIT: yes.

Reference types (mutable)

impl<'_, '_, A, B> PartialEq<&'_ B> for &'_ mut A where
    A: PartialEq<B> + ?Sized,
    B: ?Sized, 
impl<'_, '_, A, B> PartialEq<&'_ mut B> for &'_ A where
    A: PartialEq<B> + ?Sized,
    B: ?Sized, 
impl<'_, '_, A, B> PartialEq<&'_ mut B> for &'_ mut A where
    A: PartialEq<B> + ?Sized,
    B: ?Sized,

Slices

impl<A, B> PartialEq<[B]> for [A] where
    A: PartialEq<B>, 

impl<const N: usize, A, B> PartialEq<[A; N]> for [B] where
    B: PartialEq<A>,
    [A; N]: LengthAtMost32, 
impl<'b, const N: usize, A, B> PartialEq<[A; N]> for &'b [B] where
    B: PartialEq<A>,
    [A; N]: LengthAtMost32, 
impl<'b, const N: usize, A, B> PartialEq<[A; N]> for &'b mut [B] where
    B: PartialEq<A>,
    [A; N]: LengthAtMost32, 

Arrays

impl<const N: usize, A, B> PartialEq<[B; N]> for [A; N] where
    A: PartialEq<B>,
    [A; N]: LengthAtMost32,
    [B; N]: LengthAtMost32, 

impl<const N: usize, A, B> PartialEq<[B]> for [A; N] where
    A: PartialEq<B>,
    [A; N]: LengthAtMost32, 
impl<'b, const N: usize, A, B> PartialEq<&'b [B]> for [A; N] where
    A: PartialEq<B>,
    [A; N]: LengthAtMost32, 
impl<'b, const N: usize, A, B> PartialEq<&'b mut [B]> for [A; N] where
    A: PartialEq<B>,
    [A; N]: LengthAtMost32, 

Tuples

Implementation across tuples is dependent on thinking more generally about how epsilon values should apply to heterogeneous types, and whether they ought to be supported at all.

impl PartialEq<()> for ()
impl<A> PartialEq<(A,)> for (A,) where
    A: PartialEq<A> + ?Sized, 
impl<A, B> PartialEq<(A, B)> for (A, B) where
    A: PartialEq<A>,
    B: PartialEq<B> + ?Sized, 
//...
impl<A, B, C, D, E, F, G, H, I, J, K, L> PartialEq<(A, B, C, D, E, F, G, H, I, J, K, L)> for (A, B, C, D, E, F, G, H, I, J, K, L) where
    A: PartialEq<A>,
    B: PartialEq<B>,
    C: PartialEq<C>,
    D: PartialEq<D>,
    E: PartialEq<E>,
    F: PartialEq<F>,
    G: PartialEq<G>,
    H: PartialEq<H>,
    I: PartialEq<I>,
    J: PartialEq<J>,
    K: PartialEq<K>,
    L: PartialEq<L> + ?Sized, 

Vec

impl<A, B> PartialEq<Vec<B>> for Vec<A> where
    A: PartialEq<B>, 

impl<'_, A, B> PartialEq<&'_ [B]> for Vec<A> where
    A: PartialEq<B>, 
impl<'_, A, B> PartialEq<&'_ mut [B]> for Vec<A> where
    A: PartialEq<B>, 
	
impl<const N: usize, A, B> PartialEq<[B; N]> for Vec<A> where
    A: PartialEq<B>,
    [B; N]: LengthAtMost32, 
impl<'_, const N: usize, A, B> PartialEq<&'_ [B; N]> for Vec<A> where
    A: PartialEq<B>,
    [B; N]: LengthAtMost32, 

TODO: Is impl<'_, const N: usize, A, B> PartialEq<&'_ mut [B; N]> for Vec<A> missing?

VecDeque

impl<A> PartialEq<VecDeque<A>> for VecDeque<A> where
    A: PartialEq<A>, 

impl<'_, A, B> PartialEq<&'_ [B]> for VecDeque<A> where
    A: PartialEq<B>, 
impl<'_, A, B> PartialEq<&'_ mut [B]> for VecDeque<A> where
    A: PartialEq<B>, 

impl<const N: usize, A, B> PartialEq<[B; N]> for VecDeque<A> where
    A: PartialEq<B>,
    [B; N]: LengthAtMost32, 
impl<'_, const N: usize, A, B> PartialEq<&'_ [B; N]> for VecDeque<A> where
    A: PartialEq<B>,
    [B; N]: LengthAtMost32, 
impl<'_, const N: usize, A, B> PartialEq<&'_ mut [B; N]> for VecDeque<A> where
    A: PartialEq<B>,
    [B; N]: LengthAtMost32, 

impl<A, B> PartialEq<Vec<B>> for VecDeque<A> where
    A: PartialEq<B>,

Set collections

TODO: I assume that HashSet is a bad target since it requires Eq, whereas BTrees might be more amenable.

impl<T, S> PartialEq<HashSet<T, S>> for HashSet<T, S> where
    S: BuildHasher,
    T: Eq + Hash,
impl<T> PartialEq<BTreeSet<T>> for BTreeSet<T> where
    T: PartialEq<T>, 

Map collections

TODO: I assume these should these be FloatEq over just their values, since they require Eq on keys.

impl<K, V, S> PartialEq<HashMap<K, V, S>> for HashMap<K, V, S> where
    K: Eq + Hash,
    S: BuildHasher,
    V: PartialEq<V>, 
impl<K, V> PartialEq<BTreeMap<K, V>> for BTreeMap<K, V> where
    K: PartialEq<K>,
    V: PartialEq<V>, 

Result

TODO: Should this just be over T: FloatEq, or should E also be involved?

impl<T, E> PartialEq<Result<T, E>> for Result<T, E> where
    E: PartialEq<E>,
    T: PartialEq<T>,

Cow

impl<'a, 'b, B, C> PartialEq<Cow<'b, C>> for Cow<'a, B> where
    B: PartialEq<C> + ToOwned + ?Sized,
    C: ToOwned + ?Sized, 

impl<'_, '_, A, B> PartialEq<&'_ [B]> for Cow<'_, [A]> where
    A: PartialEq<B>,
    A: Clone, 	
impl<'_, '_, A, B> PartialEq<&'_ mut [B]> for Cow<'_, [A]> where
    A: PartialEq<B> + Clone, 

impl<'_, A, B> PartialEq<Vec<B>> for Cow<'_, [A]> where
    A: PartialEq<B> + Clone, 

Simple inner type

impl<T> PartialEq<Option<T>> for Option<T> where
    T: PartialEq<T>, 
impl<T> PartialEq<Box<T>> for Box<T> where
    T: PartialEq<T> + ?Sized, 
impl<T> PartialEq<Cell<T>> for Cell<T> where
    T: PartialEq<T> + Copy, 
impl<T> PartialEq<RefCell<T>> for RefCell<T> where
    T: PartialEq<T> + ?Sized, 
impl<T> PartialEq<Rc<T>> for Rc<T> where
    T: PartialEq<T> + ?Sized, 
impl<T> PartialEq<Arc<T>> for Arc<T> where
    T: PartialEq<T> + ?Sized, 
impl<T> PartialEq<LinkedList<T>> for LinkedList<T> where
    T: PartialEq<T>, 
impl<P, Q> PartialEq<Pin<Q>> for Pin<P> where
    P: Deref,
    Q: Deref,
    <P as Deref>::Target: PartialEq<<Q as Deref>::Target>, 
impl<T> PartialEq<Bound<T>> for Bound<T> where
    T: PartialEq<T>, 
impl<T> PartialEq<Poll<T>> for Poll<T> where
    T: PartialEq<T>, 
impl<T> PartialEq<Reverse<T>> for Reverse<T> where
    T: PartialEq<T>, 
impl<T> PartialEq<ManuallyDrop<T>> for ManuallyDrop<T> where
    T: PartialEq<T> + ?Sized, 
@jtempest
Copy link
Owner Author

Closed in favour of #8.

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

1 participant