Trait sgx_tstd::cmp::Eq

1.0.0 · source · []
pub trait Eq: PartialEq<Self> { }
Expand description

Trait for equality comparisons which are equivalence relations.

This means, that in addition to a == b and a != b being strict inverses, the equality must be (for all a, b and c):

  • reflexive: a == a;
  • symmetric: a == b implies b == a; and
  • transitive: a == b and b == c implies a == c.

This property cannot be checked by the compiler, and therefore Eq implies PartialEq, and has no extra methods.

Derivable

This trait can be used with #[derive]. When derived, because Eq has no extra methods, it is only informing the compiler that this is an equivalence relation rather than a partial equivalence relation. Note that the derive strategy requires all fields are Eq, which isn’t always desired.

How can I implement Eq?

If you cannot use the derive strategy, specify that your type implements Eq, which has no methods:

enum BookFormat { Paperback, Hardback, Ebook }
struct Book {
    isbn: i32,
    format: BookFormat,
}
impl PartialEq for Book {
    fn eq(&self, other: &Self) -> bool {
        self.isbn == other.isbn
    }
}
impl Eq for Book {}

Implementors

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for function pointers with up to twelve arguments.

This trait is implemented for tuples up to twelve items long.

impl Eq for AesCbc

impl Eq for Nonce

impl<A> Eq for Aad<A>where
    A: Eq,

impl Eq for Nonce

impl Eq for AesCtr

impl Eq for Counter

impl<A> Eq for Aad<A>where
    A: Eq,

impl Eq for Nonce

impl Eq for EcKeyPair

impl Eq for EcPrivateKey

impl Eq for EcPublicKey

impl Eq for EcShareKey

impl Eq for EcSignature

impl Eq for HashType

impl Eq for Sm2KeyPair

impl Eq for Sm2PrivateKey

impl Eq for Sm2PublicKey

impl Eq for Sm2ShareKey

impl Eq for Sm2Signature

impl Eq for Sm4Cbc

impl Eq for Nonce

impl<A> Eq for Aad<A>where
    A: Eq,

impl Eq for Nonce

impl Eq for Sm4Ctr

impl Eq for Counter