Mutable iteration inside of trait

⚓ Rust    📅 2025-12-17    👤 surdeus    👁️ 1      

surdeus

I have a trait that includes this:

trait MyTrait {
   type X<T>: IntoIterator<Item = T>;
}

I'd like to add a method to this trait iterates over an input of type X<A> and replaces the items it holds with something else, yielding an output of type X<B>. But IntoIterator<Item = T> does not grant something like iter_mut() (only into_iter()); what is the right syntax here?

5 posts - 5 participants

Read full topic

🏷️ Rust_feed