I blindly converted some Racket code (a dialect of Scheme) to Rust. The good news: It works and is about 5x faster than Racket. I would love some advice on how to improve this code and make it more idiomatic.
Here are my thoughts:
- I used
to_owned()in two places. Can they be avoided?
- I use
VecDequein the "merging" section of the code and
Vecin the "expression tree evaluating" section. They felt appropriate, but maybe something else is more effective or efficient?
- I pass
&mutstructures around instead of returning structures. I kind of struggled with returning references and this seemed to work OK
- My code feels clunky, for example, I couldn't get
foldto work and I also couldn't use the
HashSet::unionfunction so I ended up with a lot of
The code basically solves problem 259 at projecteuler.net (I apologize to the PE purists for posting code), which is to sum all the positive integers that result from combining all the partitions of the digits with the basic 4 arithmetic functions