Skip to content

Commit defb0e4

Browse files
committed
Remove PartialEq str for Encoding.
1 parent 199bc65 commit defb0e4

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

core/encode.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ impl PartialEq for Encoding {
3838
}
3939
}
4040

41-
impl<'a> PartialEq<&'a str> for Encoding {
42-
fn eq(&self, other: &&'a str) -> bool {
43-
self.as_str() == *other
44-
}
45-
}
46-
4741
impl fmt::Debug for Encoding {
4842
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4943
write!(f, "{}", self.as_str())
@@ -148,11 +142,11 @@ mod tests {
148142

149143
#[test]
150144
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() == ":");
157151
}
158152
}

core/examples/example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
let hash_method = cls.instance_method(hash_sel).unwrap();
3535
let hash_return = hash_method.return_type();
3636
println!("-[NSObject hash] return type: {}", &*hash_return);
37-
assert!(usize::encode() == &*hash_return);
37+
assert!(usize::encode().as_str() == &*hash_return);
3838

3939
// Invoke a method on the object
4040
let hash: usize = unsafe {

core/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl Object {
371371
let cls = self.class();
372372
let ptr = match cls.instance_variable(name) {
373373
Some(ivar) => {
374-
assert!(T::encode() == ivar.type_encoding());
374+
assert!(T::encode().as_str() == ivar.type_encoding());
375375
let offset = ivar.offset();
376376
let self_ptr = self as *const Object;
377377
(self_ptr as *const u8).offset(offset) as *const T
@@ -390,7 +390,7 @@ impl Object {
390390
let cls = self.class();
391391
let ptr = match cls.instance_variable(name) {
392392
Some(ivar) => {
393-
assert!(T::encode() == ivar.type_encoding());
393+
assert!(T::encode().as_str() == ivar.type_encoding());
394394
let offset = ivar.offset();
395395
let self_ptr = self as *mut Object;
396396
(self_ptr as *mut u8).offset(offset) as *mut T

foundation/value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub trait INSValue : INSObject {
1313
type Value: 'static + Copy + Encode;
1414

1515
fn value(&self) -> Self::Value {
16-
assert!(Self::Value::encode() == self.encoding());
16+
assert!(Self::Value::encode().as_str() == self.encoding());
1717
unsafe {
1818
let mut value = mem::uninitialized::<Self::Value>();
1919
let _: () = msg_send![self, getValue:&mut value];
@@ -70,6 +70,6 @@ mod tests {
7070
fn test_value() {
7171
let val = NSValue::from_value(13u32);
7272
assert!(val.value() == 13);
73-
assert!(u32::encode() == val.encoding());
73+
assert!(u32::encode().as_str() == val.encoding());
7474
}
7575
}

0 commit comments

Comments
 (0)