Cleanup librustpkg a little bit.

Mostly I did simple transformations from imperative style loops to
more functional iterator based transformations.
auto merge of #7866 : sstewartgallus/rust/clean, r=huonw

Mostly I did simple transformations from imperative style loops to
more functional iterator based transformations.