Trait refid::Id[][src]

pub trait Id {
    fn same(&self, other: &Self) -> bool;
fn hash<H: Hasher>(&self, state: &mut H); }
Expand description

Type that can be compared in regard to identity (e.g. through address comparison) instead of equality (as done by PartialEq)

Caveats / Notes

  • Two references (passed to same as references to the respective reference) are considered the same if they point to the same memory range. However, empty memory ranges (e.g. in case of empty slices or zero-sized types) are always considered identical, even if their base address is different.
  • Two Rcs (or two Arcs) are considered the same if they share the same reference counter (i.e. if they are clones). This also holds if their inner type is a zero-sized type.
  • Working with trait objects may cause surprising behavior due to current implementation of Id for references and Rust’s pointer comparison rules.

Required methods

Check if two values are the same

Perform hashing such that two identical values create equal hashes

Implementations on Foreign Types

References are identical if their pointer representation is equal or if they both refer to a zero-sized value

Rcs are identical if they share the same reference counter

std::rc::Weaks are identical if they share the same reference counter

Arcs are identical if they share the same reference counter

std::sync::Weaks are identical if they share the same reference counter

Implementors