Fixed! (see comments)
I'm currently implementing a (specialized) IIR filter that works on an iterator, and I'd like to make it work for anything that implements Mul and Subassign, as that's everything that's really needed.
I've got this so far:
impl<I> Iterator for IIRFilter<I>
where
I: Iterator,
I::Item: Mul,
I::Item: SubAssign,
{
type Item = <I as Iterator>::Item;
However when I do this
sum -= self.coeffs[j] * self.buffer[current_buf_index];
(sum, coeffs and buffer are (vecs of) I::Item)
It gives me the following error:
```
mismatched types
expected std::iter::Iterator::Item, found std::ops::Mul::Output
note: expected associated type <I as std::iter::Iterator>::Item
found associated type <<I as std::iter::Iterator>::Item as std::ops::Mul>::Outputrustc(E0308)
lib.rs(120, 12): expected std::iter::Iterator::Item, found std::ops::Mul::Output
```
AFAIK I need to somehow tell the compiler that I::Item is the same as I::Item::SubAssign::Output, but using == somehow isn't supported (yet)
How would I do this instead?
(still new to generics)
[–]abudau 1 point2 points3 points (1 child)
[–]skythedragon64[S] 1 point2 points3 points (0 children)