[−][src]Trait classific::EqClass
Implementations define an equivalence class over the type T
, which can be semantically
different from PartialEq::eq
.
By convention, the equivalence class should fulfill the following properties
(for all a
, b
and c
):
- reflexive:
a == a
- symmetric: if
a == b
thenb == a
- transitive: if
a == b
andb == c
thena == c
Examples
use classific::{EqClass, eq_by}; assert!(eq_by(|t: &(i8, i8)| t.1).eq(&(1, 2), &(2, 2)));
Required methods
fn eq(&self, left: &T, right: &T) -> bool
This method tests for left
and right
values to be equal.
Examples
use classific::{EqClass, natural_eq}; assert!(natural_eq().eq(&1, &1));
Provided methods
fn and<N>(self, next: N) -> BothEq<T, Self, N> where
Self: Sized,
N: EqClass<T>,
Self: Sized,
N: EqClass<T>,
This method returns an EqClass
which is further refining the semantics of self
.
Both self::eq
and next::eq
is called
and the result is true
if and only if both returned true
.
Examples
use classific::{EqClass, eq_by}; assert!(eq_by(|t: &(i8, i8, i8)| t.0).and(eq_by(|t: &(i8, i8, i8)| t.1)).eq(&(1, 2, 3), &(1, 2, 1)));
Implementors
impl<S, T, F> EqClass<S> for EqBy<S, T, F> where
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> T,
[src]
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> T,
impl<S, T, F, C> EqClass<S> for EqByWith<S, T, F, C> where
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> T,
C: EqClass<T>,
[src]
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> T,
C: EqClass<T>,
impl<S, T: ?Sized, F> EqClass<S> for EqByRef<S, T, F> where
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> &T,
[src]
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> &T,
impl<S, T: ?Sized, F, C> EqClass<S> for EqByRefWith<S, T, F, C> where
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> &T,
C: EqClass<T>,
[src]
S: ?Sized,
T: PartialEq<T>,
F: Fn(&S) -> &T,
C: EqClass<T>,
impl<T, C> EqClass<T> for EqByCmp<T, C> where
T: ?Sized,
C: Comparator<T>,
[src]
T: ?Sized,
C: Comparator<T>,
impl<T, C, N> EqClass<T> for BothEq<T, C, N> where
T: ?Sized,
C: EqClass<T>,
N: EqClass<T>,
[src]
T: ?Sized,
C: EqClass<T>,
N: EqClass<T>,
impl<T, F> EqClass<T> for F where
T: ?Sized,
F: Fn(&T, &T) -> bool,
[src]
T: ?Sized,
F: Fn(&T, &T) -> bool,
impl<T: ?Sized> EqClass<T> for EqByHash<T> where
T: Hash,
[src]
T: Hash,
impl<T: ?Sized> EqClass<T> for NaturalEq<T> where
T: PartialEq<T>,
[src]
T: PartialEq<T>,
impl<T: ?Sized> EqClass<T> for PartialEqClass<T> where
T: PartialEq<T>,
[src]
T: PartialEq<T>,