Refactor non-idiomatic Rust code.