How do I box trait involving `Clone`?

The intention of the playground code is that I want to box Iterator + Clone into a single variable so I don't have to duplicate complex logic.

In this example, the function requires_clone_iterator is simple but in my actual code it's actually 4 iterator extension method call with 4 match arms so I need to write 16 iterator extension method calls.

Is boxing Clone trait or similar method possible? Or, should I just create generic function to do this?

It's possible.

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.