Skip to content

Commit d75c1b0

Browse files
committed
Updated foundation to fix warnings with alpha2.
1 parent 83f4f4a commit d75c1b0

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![crate_name = "objc_foundation"]
22
#![crate_type = "lib"]
33

4-
#![feature(collections, core, hash, std_misc)]
4+
#![feature(collections, core, std_misc)]
55

66
extern crate libc;
77
#[macro_use]

value.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ffi::{CString, self};
1+
use std::ffi::{CStr, CString};
22
use std::marker::PhantomData;
33
use std::mem;
44
use std::str;
@@ -24,15 +24,14 @@ pub trait INSValue : INSObject {
2424
fn encoding(&self) -> &str {
2525
unsafe {
2626
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()
3029
}
3130
}
3231

3332
fn from_value(value: Self::Value) -> Id<Self> {
3433
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();
3635
unsafe {
3736
let obj: *mut Self = msg_send![cls, alloc];
3837
let obj: *mut Self = msg_send![obj, initWithBytes:&value

0 commit comments

Comments
 (0)