File tree 4 files changed +11
-17
lines changed
4 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -38,12 +38,6 @@ impl PartialEq for Encoding {
38
38
}
39
39
}
40
40
41
- impl < ' a > PartialEq < & ' a str > for Encoding {
42
- fn eq ( & self , other : & & ' a str ) -> bool {
43
- self . as_str ( ) == * other
44
- }
45
- }
46
-
47
41
impl fmt:: Debug for Encoding {
48
42
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
49
43
write ! ( f, "{}" , self . as_str( ) )
@@ -148,11 +142,11 @@ mod tests {
148
142
149
143
#[ test]
150
144
fn test_encode ( ) {
151
- assert ! ( u32 :: encode( ) == encode! ( u32 ) ) ;
152
- assert ! ( <( ) >:: encode( ) == "v" ) ;
153
- assert ! ( <& Object >:: encode( ) == "@" ) ;
154
- assert ! ( <* mut Object >:: encode( ) == "@" ) ;
155
- assert ! ( <& Class >:: encode( ) == "#" ) ;
156
- assert ! ( Sel :: encode( ) == encode! ( Sel ) ) ;
145
+ assert ! ( u32 :: encode( ) . as_str ( ) == "I" ) ;
146
+ assert ! ( <( ) >:: encode( ) . as_str ( ) == "v" ) ;
147
+ assert ! ( <& Object >:: encode( ) . as_str ( ) == "@" ) ;
148
+ assert ! ( <* mut Object >:: encode( ) . as_str ( ) == "@" ) ;
149
+ assert ! ( <& Class >:: encode( ) . as_str ( ) == "#" ) ;
150
+ assert ! ( Sel :: encode( ) . as_str ( ) == ":" ) ;
157
151
}
158
152
}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ fn main() {
34
34
let hash_method = cls. instance_method ( hash_sel) . unwrap ( ) ;
35
35
let hash_return = hash_method. return_type ( ) ;
36
36
println ! ( "-[NSObject hash] return type: {}" , & * hash_return) ;
37
- assert ! ( usize :: encode( ) == & * hash_return) ;
37
+ assert ! ( usize :: encode( ) . as_str ( ) == & * hash_return) ;
38
38
39
39
// Invoke a method on the object
40
40
let hash: usize = unsafe {
Original file line number Diff line number Diff line change @@ -371,7 +371,7 @@ impl Object {
371
371
let cls = self . class ( ) ;
372
372
let ptr = match cls. instance_variable ( name) {
373
373
Some ( ivar) => {
374
- assert ! ( T :: encode( ) == ivar. type_encoding( ) ) ;
374
+ assert ! ( T :: encode( ) . as_str ( ) == ivar. type_encoding( ) ) ;
375
375
let offset = ivar. offset ( ) ;
376
376
let self_ptr = self as * const Object ;
377
377
( self_ptr as * const u8 ) . offset ( offset) as * const T
@@ -390,7 +390,7 @@ impl Object {
390
390
let cls = self . class ( ) ;
391
391
let ptr = match cls. instance_variable ( name) {
392
392
Some ( ivar) => {
393
- assert ! ( T :: encode( ) == ivar. type_encoding( ) ) ;
393
+ assert ! ( T :: encode( ) . as_str ( ) == ivar. type_encoding( ) ) ;
394
394
let offset = ivar. offset ( ) ;
395
395
let self_ptr = self as * mut Object ;
396
396
( self_ptr as * mut u8 ) . offset ( offset) as * mut T
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ pub trait INSValue : INSObject {
13
13
type Value : ' static + Copy + Encode ;
14
14
15
15
fn value ( & self ) -> Self :: Value {
16
- assert ! ( Self :: Value :: encode( ) == self . encoding( ) ) ;
16
+ assert ! ( Self :: Value :: encode( ) . as_str ( ) == self . encoding( ) ) ;
17
17
unsafe {
18
18
let mut value = mem:: uninitialized :: < Self :: Value > ( ) ;
19
19
let _: ( ) = msg_send ! [ self , getValue: & mut value] ;
@@ -70,6 +70,6 @@ mod tests {
70
70
fn test_value ( ) {
71
71
let val = NSValue :: from_value ( 13u32 ) ;
72
72
assert ! ( val. value( ) == 13 ) ;
73
- assert ! ( u32 :: encode( ) == val. encoding( ) ) ;
73
+ assert ! ( u32 :: encode( ) . as_str ( ) == val. encoding( ) ) ;
74
74
}
75
75
}
You can’t perform that action at this time.
0 commit comments