RS.CLIPPY.MANUAL_MEMCPY

Manually copying items between slices

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: manual_memcpy. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for for-loops that manually copy items between slices that could be optimized by having a memcpy.

Why is this bad?

It is not as fast as a memcpy.

Example

for i in 0..src.len() {
    dst[i + 64] = src[i];
}

Use instead:

dst[64..(src.len() + 64)].clone_from_slice(&src[..]);