Hello everybody,

after applying a few combinators to a slice of objects `&[T]`

I end up with a slice of references `&[&T]`

which I like to process in another function. So the function parameter must be of type `&[&T]`

. In order to reuse this function, I have to convert slice of objects to slices of references which is cumbersome and feels wrong. I’m wondering, if I’m missing something here which would allow me to resolve this in a more elegant way.

Here is a simplified example – cf. Playground.

```
struct Age {
pub age: u32,
}
fn process_ages(ages: &[Option<Age>]) -> u32 {
let somes: Vec<&Age> = ages.iter()
.filter(|x| x.is_some())
.map(|x| x.as_ref().unwrap())
.collect();
sum_ages(&somes)
}
fn sum_ages(ages: &[&Age]) -> u32 {
ages.iter().fold(0, |acc, e| acc + e.age)
}
fn main() {
let ages: Vec<Option<Age>> = vec![Some(Age { age: 1 }), None, Some(Age { age: 2 })];
assert_eq!(process_ages(&ages), 3);
}
```

In this example, the total sum of all ages from a list of `Option<Age>`

s should be computed. The function of interest is `sum_ages`

that takes a slice of type `&[&Age]`

instead a of slice of `&[Age]`

which is more general and more applicable.

Do you have any idea how to ease the pain and make `sum_ages`

reusable without requiring a transformation of `&[&Age]`

to `&[&Age]`

all the time?

Thanks in advance!