Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernization and cleanup #69

Merged
merged 8 commits into from Sep 5, 2015
Merged

Clean up set

* Abstract from_slice over TCFType
  • Loading branch information
sfackler committed Aug 29, 2015
commit edaea4de45f37109fc6f20b124a47d1ea730d47f
@@ -10,7 +10,7 @@
//! An immutable bag of elements.

use base::{CFAllocatorRef, CFIndex, CFIndexConvertible, CFRelease, CFRetain};
use base::{CFType, CFTypeID, CFTypeRef, TCFType, kCFAllocatorDefault};
use base::{CFTypeID, CFTypeRef, TCFType, kCFAllocatorDefault};

use libc::c_void;
use std::mem;
@@ -88,7 +88,7 @@ impl TCFType<CFSetRef> for CFSet {

impl CFSet {
/// Creates a new set from a list of `CFType` instances.
pub fn from_slice(elems: &[CFType]) -> CFSet {
pub fn from_slice<R, T: TCFType<R>>(elems: &[T]) -> CFSet {
unsafe {
let elems: Vec<CFTypeRef> = elems.iter().map(|elem| elem.as_CFTypeRef()).collect();
let set_ref = CFSetCreate(kCFAllocatorDefault,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.