I am trying to add a convenience method to the Vec<T> type. I believe using a trait is the correct way to do this, but could be wrong. Below is what I have so far, which complains that
trait objects must include the `dyn` keyword
What am I doing wrong?
trait IndexWhere<T> {
fn index_where(&self, f: Fn((usize, T)) -> bool) -> Vec<usize>;
}
impl<T> IndexWhere<T> for Vec<T> {
fn index_where(&self, f: Fn((usize, T)) -> bool) -> Vec<usize> {
self.iter().enumerate().filter(f).map(|x| x.0).collect()
}
}
edit: removed bounds on T as I added them by accident