File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
#![ crate_name = "objc_foundation" ]
2
2
#![ crate_type = "lib" ]
3
3
4
- #![ feature( collections, core, hash , std_misc) ]
4
+ #![ feature( collections, core, std_misc) ]
5
5
6
6
extern crate libc;
7
7
#[ macro_use]
Original file line number Diff line number Diff line change 1
- use std:: ffi:: { CString , self } ;
1
+ use std:: ffi:: { CStr , CString } ;
2
2
use std:: marker:: PhantomData ;
3
3
use std:: mem;
4
4
use std:: str;
@@ -24,15 +24,14 @@ pub trait INSValue : INSObject {
24
24
fn encoding ( & self ) -> & str {
25
25
unsafe {
26
26
let result: * const c_char = msg_send ! [ self , objCType] ;
27
- let bytes = ffi:: c_str_to_bytes ( & result) ;
28
- let s = str:: from_utf8 ( bytes) . unwrap ( ) ;
29
- mem:: transmute ( s)
27
+ let s = CStr :: from_ptr ( result) ;
28
+ str:: from_utf8 ( s. to_bytes ( ) ) . unwrap ( )
30
29
}
31
30
}
32
31
33
32
fn from_value ( value : Self :: Value ) -> Id < Self > {
34
33
let cls = <Self as INSObject >:: class ( ) ;
35
- let encoding = CString :: from_slice ( encode :: < Self :: Value > ( ) . as_bytes ( ) ) ;
34
+ let encoding = CString :: new ( encode :: < Self :: Value > ( ) ) . unwrap ( ) ;
36
35
unsafe {
37
36
let obj: * mut Self = msg_send ! [ cls, alloc] ;
38
37
let obj: * mut Self = msg_send ! [ obj, initWithBytes: & value
You can’t perform that action at this time.
0 commit comments