I have a function that has the following signature:
pub fn find_if<I, P>(mut f : I, l : &I, mut p : P) -> I
where I : Iterator + Readable, P : FnMut(&I::value_type) -> bool
I wanted to replace the function trait like this:
pub trait UnaryPredicate<Domain> : FnMut(Domain) -> bool {}
impl<T, D> UnaryPredicate<D> for T where T : FnMut(D) -> bool {}
and the original signature now becomes:
pub fn find_if<I, P>(mut f : I, l : &I, mut p : P) -> I
where I : Iterator + Readable, P : UnaryPredicate<&I::value_type>
The original version compiled without problems, but the new version gives me the following error:
error: : missing lifetime specifier
If I add a lifetime specifier, it still does not work, so there is something else wrong as well.
Why does it not need a lifetime specifier when using FnMut function trait directly, but it needs one when using UnaryPredicate?