implement PartialEq for MutHeap<JS<T>> and MutNullableHeap<JS<T>>

This commit is contained in:
Rohan Prinja 2015-10-21 01:40:19 +09:00
parent 36d5c0b2fb
commit ab70c8c942

View file

@ -260,6 +260,12 @@ impl<T: HeapGCValue> HeapSizeOf for MutHeap<T> {
} }
} }
impl<T: Reflectable> PartialEq for MutHeap<JS<T>> {
fn eq(&self, other: &MutHeap<JS<T>>) -> bool {
self.get().eq(&other.get())
}
}
/// A holder that provides interior mutability for GC-managed values such as /// A holder that provides interior mutability for GC-managed values such as
/// `JS<T>`, with nullability represented by an enclosing Option wrapper. /// `JS<T>`, with nullability represented by an enclosing Option wrapper.
/// Essentially a `Cell<Option<JS<T>>>`, but safer. /// Essentially a `Cell<Option<JS<T>>>`, but safer.
@ -337,6 +343,12 @@ impl<T: HeapGCValue> HeapSizeOf for MutNullableHeap<T> {
} }
} }
impl<T: Reflectable> PartialEq for MutNullableHeap<JS<T>> {
fn eq(&self, other: &MutNullableHeap<JS<T>>) -> bool {
self.get().eq(&other.get())
}
}
impl<T: Reflectable> LayoutJS<T> { impl<T: Reflectable> LayoutJS<T> {
/// Returns an unsafe pointer to the interior of this JS object. This is /// Returns an unsafe pointer to the interior of this JS object. This is
/// the only method that be safely accessed from layout. (The fact that /// the only method that be safely accessed from layout. (The fact that