Trait same::Same[][src]

pub trait Same {
    fn same(&self, other: &Self) -> bool;
}

Allows to test identity of objects.

Example:

use same::Same;

let a = 42;
let b = 42;
let a_ref0 = &a;
let a_ref1 = &a;
let b_ref = &b;

// `a_ref0` and `a_ref1` point to the same object...
assert!(a_ref0.same(&a_ref1));
// ... but `a_ref0` and `b_ref` don't...
assert!(!a_ref0.same(&b_ref));
// ... neither do `a_ref1` and `b_ref`.
assert!(!a_ref1.same(&b_ref));

This trait is currently implemented for shared references, Rc and Arc.

Note that it doesn't make sense to implement this trait for mutable references, nor boxes because there can never be two of them pointing to the same address, so the implementation would always return false.

Required Methods

Returns true if self is the same instance of object as other.

Implementations on Foreign Types

impl<'a, T> Same for &'a T
[src]

impl<T> Same for Rc<T>
[src]

impl<T> Same for Arc<T>
[src]

Implementors