mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Impl PartialEq and Eq for DomObject (#33212)
* Impl PartialEq and Eq for DomObject Signed-off-by: Taym <haddadi.taym@gmail.com> * move to Eq and PartialEq to domobject_derive Signed-off-by: Taym <haddadi.taym@gmail.com> --------- Signed-off-by: Taym <haddadi.taym@gmail.com>
This commit is contained in:
parent
31e84a8c48
commit
6c0394bc80
3 changed files with 8 additions and 12 deletions
|
@ -57,6 +57,14 @@ fn expand_dom_object(input: syn::DeriveInput) -> proc_macro2::TokenStream {
|
||||||
self.#first_field_name.init_reflector(obj);
|
self.#first_field_name.init_reflector(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl #impl_generics Eq for #name #ty_generics #where_clause {}
|
||||||
|
|
||||||
|
impl #impl_generics PartialEq for #name #ty_generics #where_clause {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
crate::DomObject::reflector(self) == crate::DomObject::reflector(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut params = proc_macro2::TokenStream::new();
|
let mut params = proc_macro2::TokenStream::new();
|
||||||
|
|
|
@ -3056,12 +3056,6 @@ impl IDLInterface for {name} {{
|
||||||
{check}
|
{check}
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
impl PartialEq for {name} {{
|
|
||||||
fn eq(&self, other: &{name}) -> bool {{
|
|
||||||
self as *const {name} == other
|
|
||||||
}}
|
|
||||||
}}
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,12 +52,6 @@ pub struct Promise {
|
||||||
permanent_js_root: Heap<JSVal>,
|
permanent_js_root: Heap<JSVal>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for Promise {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.reflector == other.reflector
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Private helper to enable adding new methods to `Rc<Promise>`.
|
/// Private helper to enable adding new methods to `Rc<Promise>`.
|
||||||
trait PromiseHelper {
|
trait PromiseHelper {
|
||||||
fn initialize(&self, cx: SafeJSContext);
|
fn initialize(&self, cx: SafeJSContext);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue