mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
add equal() methods for comparisons with other types
This commit is contained in:
parent
5e8dc366de
commit
d9f8f68615
1 changed files with 11 additions and 1 deletions
|
@ -251,6 +251,11 @@ impl<T: Reflectable> MutHeap<JS<T>> {
|
||||||
ptr::read(self.val.get()).root()
|
ptr::read(self.val.get()).root()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Compare this object to an `&T` value.
|
||||||
|
fn eq(&self, other: &T) -> bool {
|
||||||
|
self.get() == Root::from_ref(other)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: HeapGCValue> HeapSizeOf for MutHeap<T> {
|
impl<T: HeapGCValue> HeapSizeOf for MutHeap<T> {
|
||||||
|
@ -325,6 +330,11 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
||||||
*self.ptr.get() = val.map(|p| JS::from_ref(p));
|
*self.ptr.get() = val.map(|p| JS::from_ref(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Compare this object to an `Option<&T>` value.
|
||||||
|
fn equal(&self, other: Option<&T>) -> bool {
|
||||||
|
self.get() == other.map(|p| Root::from_ref(p))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: HeapGCValue> Default for MutNullableHeap<T> {
|
impl<T: HeapGCValue> Default for MutNullableHeap<T> {
|
||||||
|
@ -344,7 +354,7 @@ impl<T: HeapGCValue> HeapSizeOf for MutNullableHeap<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable> PartialEq for MutNullableHeap<JS<T>> {
|
impl<T: Reflectable> PartialEq for MutNullableHeap<JS<T>> {
|
||||||
fn eq(&self, other: &Self>) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.get().eq(&other.get())
|
self.get().eq(&other.get())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue