pub struct ByIdDeref<T>(pub T)
where
T: Deref + ?Sized,
<T as Deref>::Target: Id;Expand description
Similar to ById, but uses identity as defined by the dereferenced inner value
This can, for example, be used to wrap references to Rcs (or Arcs) while the identity
depends on the referenced Rc or Arc).
§Example:
use std::rc::Rc;
use refid::{ById, ByIdDeref};
let rc1 = Rc::new(());
let rc2 = Rc::new(());
let rc3 = rc1.clone();
assert_ne!(ByIdDeref(&rc1.clone()), ByIdDeref(&rc2.clone()));
assert_eq!(ByIdDeref(&rc1.clone()), ByIdDeref(&rc3.clone()));
// compare with:
assert_ne!(ById(&rc1.clone()), ById(&rc2.clone()));
assert_ne!(ById(&rc1.clone()), ById(&rc3.clone()));Tuple Fields§
§0: Tinner value
(which can be dereferenced to a reference or another type that implements Id)
Trait Implementations§
impl<T> Copy for ByIdDeref<T>
impl<T> Eq for ByIdDeref<T>
Auto Trait Implementations§
impl<T> Freeze for ByIdDeref<T>
impl<T> RefUnwindSafe for ByIdDeref<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for ByIdDeref<T>
impl<T> Sync for ByIdDeref<T>
impl<T> Unpin for ByIdDeref<T>
impl<T> UnwindSafe for ByIdDeref<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more