Skip to content

Commit 61c88f9

Browse files
committed
Implement EventList for lists of options of anything that can deref to Event
1 parent a309353 commit 61c88f9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/hl.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::ffi::CString;
66
use std::iter::repeat;
77
use std::marker::PhantomData;
88
use std::mem;
9+
use std::ops::Deref;
910
use std::ptr;
1011
use std::string::String;
1112
use std::vec::Vec;
@@ -826,13 +827,13 @@ impl<'r> EventList for &'r [Event] {
826827
}
827828
}
828829

829-
impl<'r, 's> EventList for &'r [Option<&'s Event>] {
830+
impl<'r, 's, D: Deref<Target=&'s Event>> EventList for &'r [Option<D>] {
830831
fn as_event_list<T, F>(&self, f: F) -> T
831832
where F: FnOnce(*const cl_event, cl_uint) -> T
832833
{
833834
let mut vec: Vec<cl_event> = Vec::with_capacity(self.len());
834-
for item in self.iter(){
835-
if let Some(item) = *item {
835+
for item in self.iter() {
836+
if let Some(ref item) = *item {
836837
vec.push(item.event);
837838
}
838839
}

0 commit comments

Comments
 (0)