Skip to content

Commit 284344a

Browse files
committed
Require that INSObject be imported.
This will allow the derive to work within objc-foundation.
1 parent f913f37 commit 284344a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

derive/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn impl_object(input: TokenStream) -> TokenStream {
2727
).to_tokens(&mut gen);
2828

2929
quote!(
30-
impl #impl_generics ::objc_foundation::INSObject for #name #ty_generics #where_clause {
30+
impl #impl_generics INSObject for #name #ty_generics #where_clause {
3131
fn class() -> &'static ::objc::runtime::Class {
3232
extern {
3333
#[link_name = #link_name]
@@ -43,26 +43,24 @@ pub fn impl_object(input: TokenStream) -> TokenStream {
4343
quote!(
4444
impl #impl_generics ::std::cmp::PartialEq for #name #ty_generics #where_clause {
4545
fn eq(&self, other: &Self) -> bool {
46-
use ::objc_foundation::INSObject;
47-
self.is_equal(other)
46+
INSObject::is_equal(self, other)
4847
}
4948
}
5049
).to_tokens(&mut gen);
5150

5251
quote!(
5352
impl #impl_generics ::std::hash::Hash for #name #ty_generics #where_clause {
5453
fn hash<H>(&self, state: &mut H) where H: ::std::hash::Hasher {
55-
use ::objc_foundation::INSObject;
56-
self.hash_code().hash(state);
54+
INSObject::hash_code(self).hash(state);
5755
}
5856
}
5957
).to_tokens(&mut gen);
6058

6159
quote!(
6260
impl #impl_generics ::std::fmt::Debug for #name #ty_generics #where_clause {
6361
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
64-
use ::objc_foundation::{INSObject, INSString};
65-
::std::fmt::Debug::fmt(self.description().as_str(), f)
62+
let s = INSObject::description(self);
63+
::std::fmt::Display::fmt(&*s, f)
6664
}
6765
}
6866
).to_tokens(&mut gen);

0 commit comments

Comments
 (0)