In the following snippet:
let b: Vec<usize> = a.iter().filter(|x| **x > 5).map(|x| *x).collect();
Is there a nicer way to make b be a vector of values rather than references? (instead of .map(|x| *x))
Is there something like:
fn iter_values<T : Copy>(c: &Vec<T>) -> std::iter::Map<std::slice::Iter<T>, fn(&T) -> T> {
c.iter().map(|x| *x)
}
That can be used like so:
let b: Vec<usize> = iter_values(&a).filter(|x| *x > 5).collect();