Any way to avoid iterating by index?

⚓ Rust    📅 2025-08-22    👤 surdeus    👁️ 4      

surdeus

Given the following case:

code (click for more details)

Is there any way to avoid:

compiler error (click for more details)

Without resorting to an index-based workaround via .iter().enumerate() or equivalent? It seems to be a rather straightforward reference flow for the borrow checker to handle, yet none of my attempts seem to have worked so far.

Including those to manually drop the similar itself, self.list.iter() saved to a separate variable beforehand, or manual 0..self.list.len() iteration with borrowing by index.

2 posts - 2 participants

Read full topic

🏷️ Rust_feed