Yesterday I played around a bit with a little programming exercise:
Calculate the sum of an array which contains integers and other arrays with integers.
For example: array_sum([1,2,[3,4,]]) would return 15.
Here’s my Python and PHP solutions:
Coming from dynamically typed languages it was surprisingly hard to wrap my head around a strongly typed solution.
I have an idea on how to solve this in Rust, although it might not be the most idiomatic.
Therefore I’d like to hear from you what would be a “Rustic” way to solve this problem.
Since I don’t want to influence you in any way I will not post my solution just yet.
Bonus points if you can make your solution generic enough to also handle other collection types.