In the code below, I get cannot assign to 'self.index' because it is borrowed compiler error in the line self.index = tmp;
I understand that Self was borrowed by f1, but do not understand, why compiler is complaining, after f1 has already returned - which should mean the scope of the borrow must have ended.
Please help me understand what is going on here and what is the solution.
Note that unconstrained (i.e. not attached to any input) lifetime parameter in the return value is equivalent to 'static - it is chosen by the caller, so it can be 'static, if they choose, but then you must return something that is indeed 'static; therefore, you can use &'static str instead of &'b str without change in semantics.