error[E0207]: the type parameter `I` is not constrained by the impl trait, self type, or predicates
--> arkley_algebra\src\arithmetics\div.rs:137:9
|
137 | impl<'a,I> std::ops::Div for Expression where Self : VariableAnalysis<'a,I> , I : Iterator<Item = &'a char> {
| ^ unconstrained type parameter
I don't understand is I not constrained by impl and self ?
impl<'a,I> VariableAnalysis<'a, I> for Expression ... says that VariableAnalysis is be implemented for any'a and I that satisfy the bounds. In the Div implementation, there is no means by which a caller of div() can choose which of those iterator types should apply.
Usually when this comes up, it means you need the trait to have an associated type instead of a type parameter. However, that likely does not apply straightforwardly here given the lifetime 'a.
If you show us more of what the trait does (unredact those // ..), we might be able to give a better suggestion.
This isn't a workaround — it's the correct choice, because whether and howVariableAnalysis is implemented doesn't depend on the iterator type. If it's implemented at all, it works with every iterator.
Also, you should stop using &char as the item type — there is no point in passing small types like that by reference. Pass char instead; it may be be more efficient, and it will certainly be more convenient to avoid the lifetime parameters. Convert iterators to fit this like so: .iter().copied().
Also, you should stop using &char as the item type
The reason I chose this was i use the methods very often and I only need to compare the items with each other basically like &char == &'.' . So in that case I think using a reference is much better (but I may be wrong)