cleanup rust code
There are low-hanging fruit for silencing clippy lints, removing unnecessary allocations, and writing a more efficient version of `.retain()`. **Trac**: **Username**: cyberpunks
issue