Optimize Vec::retain by oxalica · Pull Request #81126 · rust-lang/rust

Use copy_non_overlapping instead of swap to reduce memory writes, like what we've done in #44355 and String::retain. #48065 already tried to do this optimization but it is reverted in #67300 due to...