I don't want to run in the x-y-problem, so this is what I am trying to achieve:
I want to finally have a
PartialEq implementation for a Mutex.
Comparing it in a single threaded environment would be to just lock the mutex temporarily and the
other mutex and then compare the dereferenced values like this:
let first = Mutex::new(1); let other = Mutex::new(1); assert!(first.lock().unwrap().deref() == other.lock().unwrap().deref());
This can cause problems with an
Rc, because the above code would result in a deadlock.
Implementing the trait directly will give me access to the internal UnsafeCell, which should make it possible to check if they point to the same location, by doing something like this
let cell = /* UnsafeCell<T> */; let other_cell = /* UnsafeCell<T> which is the same cell as `cell`*/; assert!(cell.get() == other_cell.get());