diff --git a/src/lib.rs b/src/lib.rs index 0f0c117..22f0ea1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ #![allow(non_snake_case)] -#![feature(core, libc, collections)] +#![feature(core, libc)] extern crate libc; diff --git a/src/string.rs b/src/string.rs index 44d7807..2843f6a 100644 --- a/src/string.rs +++ b/src/string.rs @@ -263,9 +263,11 @@ impl TCFType for CFString { } impl FromStr for CFString { + type Err = (); + /// Creates a new `CFString` instance from a Rust string. #[inline] - fn from_str(string: &str) -> Option { + fn from_str(string: &str) -> Result { unsafe { let string_ref = CFStringCreateWithBytes(kCFAllocatorDefault, string.as_ptr(), @@ -273,7 +275,7 @@ impl FromStr for CFString { kCFStringEncodingUTF8, false as Boolean, kCFAllocatorNull); - Some(TCFType::wrap_under_create_rule(string_ref)) + Some(TCFType::wrap_under_create_rule(string_ref)).ok_or(()) } } }