Hi, I'm trying to implement iter_mut for an struct that represents a linked list and contains a reference to a pool of elements, but I am having a problem with:
cannot infer an appropriate lifetime for autoref due to conflicting requirements
After reading different answers in internet (for example this) I can understand why is it failing. But I can not figure out how to do it right.
This code has to work with no-std, that's why I'm implementing my own pool. The purpose of the Modulations struct is to handle multiple linked lists using a single pool of elements, while ParamModulationsMut represents a mutable view to a single linked list.
The problem is reproduced here:
I'd appreciate if someone could help me figure out a solution to provide a mutable iterator for ParamModulationsMut.
Note also that I changed how the lifetimes work on the iter_mut method. You never want to take the generic lifetime on the struct itself and put it on &mut self as that makes the method near-impossible to use.
Thanks @alice, that's good advice. In my specific case, I'd need to go into unsafe world then, because there is no underlying iterator I could use.
But I think I'll try to re-think the whole design to avoid it.
Best.