I'm attemping to make a struct with a Filter iterator inside:
struct Foo {
inner_iter: Filter<...>,
}
I'm then going to make Foo an Iterator itself, which will use the Filter internally.
The problem is, I can't seem to figure out what goes in between the braces after Filter. The docs say Filter is the following:
pub struct Filter<'a, A, T> {
// some fields omitted
}
A seems to be my return type. What are 'a and T? Nothing I attempt makes it compile.
Thanks!
You can see here that
FilterimplementsIteratortrait in the following way:This means that yes,
Ais its element type, andTis underlying iterator type. If you look intoFilterdefinition, you will also find that'ais lifetime of environment of predicate closure.If you want to make your own wrapper for the
Filter, it could look like this:You need to pass through all parameters to
Filter. Of course, if you're working with some specific element type, you can specify it instead of using type parameter:However, you still need to pass
'aandTbecause they are likely to be arbitrary.