Elements of Programming in Rust

I have been working on implementing the algorithms and concepts in Stepanov's "Elements of Programming" in Rust. I have started with chapter 6 "Iterators" as I think it involves the most complex type mechanics, and if it is possible to translate this, the rest should be doable. I have posted what I have so far which is all the plain Iterator algorithms as I now think it will be possible to complete the translation.

There are some issues:

- I cannot define the dereference operators to work on values (they should be the identity function on values), this limits the generality of algorithms, in that we cannot write an algorithm that will operate on both a value and an iterator.
- I am not happy with passing some arguments by moved values, and some by borrowed reference as it makes the function APIs harder to work with, but at the moment I can see no alternative. Ideally there should be a way of defining an algorithm generically over both.
- Currently I am passing closures by moved value as this makes them cleaner to pass in, but this means where a closure is passed to other functions more than once, as reference has to be taken. This will cause problems in there recursive case where there will be an accumulation of references with recursion depth, however auto-dereferencing in function application stops the code getting ugly. I am not sure if this results in a performance issue. One solution would be to pass all closures by mutable-reference, but I am not sure this is the best answer.

Here's the link to the repo: https://github.com/keean/elements_in_rust

I am interested in comments about improving the implementation, how generic programming looks in Rust, how Rust could be improved to deal with the issues above, and any other issues that people can spot.