Skip to content

Commit a71a2ea

Browse files
committed
Implement more traits.
1 parent e3e4ae1 commit a71a2ea

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

derive/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![recursion_limit = "128"]
12
#![feature(proc_macro, proc_macro_lib)]
23

34
extern crate proc_macro;
@@ -34,6 +35,27 @@ pub fn impl_object(input: TokenStream) -> TokenStream {
3435
}
3536
}
3637
}
38+
39+
impl #impl_generics ::std::cmp::PartialEq for #name #ty_generics #where_clause {
40+
fn eq(&self, other: &Self) -> bool {
41+
use ::objc_foundation::INSObject;
42+
self.is_equal(other)
43+
}
44+
}
45+
46+
impl #impl_generics ::std::hash::Hash for #name #ty_generics #where_clause {
47+
fn hash<H>(&self, state: &mut H) where H: ::std::hash::Hasher {
48+
use ::objc_foundation::INSObject;
49+
self.hash_code().hash(state);
50+
}
51+
}
52+
53+
impl #impl_generics ::std::fmt::Debug for #name #ty_generics #where_clause {
54+
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
55+
use ::objc_foundation::{INSObject, INSString};
56+
::std::fmt::Debug::fmt(self.description().as_str(), f)
57+
}
58+
}
3759
};
3860

3961
// Return the generated impl

0 commit comments

Comments
 (0)