From 2a30fb7355706fec24d3381f20d1243a376d3386 Mon Sep 17 00:00:00 2001 From: bobakker Date: Tue, 3 Feb 2015 18:35:08 +0100 Subject: [PATCH] Fix for rust nightly Compiles and passes all tests. --- src/lib.rs | 2 +- src/string.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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(()) } } }