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=cmr

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