File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use std::mem;
4
4
use std:: str;
5
5
use libc:: c_char;
6
6
7
- use objc:: Encode ;
7
+ use objc:: { Encode , Encoding } ;
8
8
use objc:: runtime:: Class ;
9
9
use objc_id:: Id ;
10
10
@@ -14,19 +14,20 @@ pub trait INSValue : INSObject {
14
14
type Value : ' static + Copy + Encode ;
15
15
16
16
fn value ( & self ) -> Self :: Value {
17
- assert ! ( Self :: Value :: encode( ) . as_str ( ) == self . encoding( ) ) ;
17
+ assert ! ( Self :: Value :: encode( ) == self . encoding( ) ) ;
18
18
unsafe {
19
19
let mut value = mem:: uninitialized :: < Self :: Value > ( ) ;
20
20
let _: ( ) = msg_send ! [ self , getValue: & mut value] ;
21
21
value
22
22
}
23
23
}
24
24
25
- fn encoding ( & self ) -> & str {
25
+ fn encoding ( & self ) -> Encoding {
26
26
unsafe {
27
27
let result: * const c_char = msg_send ! [ self , objCType] ;
28
28
let s = CStr :: from_ptr ( result) ;
29
- str:: from_utf8 ( s. to_bytes ( ) ) . unwrap ( )
29
+ let s = str:: from_utf8 ( s. to_bytes ( ) ) . unwrap ( ) ;
30
+ Encoding :: from_str ( s)
30
31
}
31
32
}
32
33
@@ -71,6 +72,6 @@ mod tests {
71
72
fn test_value ( ) {
72
73
let val = NSValue :: from_value ( 13u32 ) ;
73
74
assert ! ( val. value( ) == 13 ) ;
74
- assert ! ( u32 :: encode( ) . as_str ( ) == val. encoding( ) ) ;
75
+ assert ! ( u32 :: encode( ) == val. encoding( ) ) ;
75
76
}
76
77
}
You can’t perform that action at this time.
0 commit comments