Out with std.mem.copy, in with @memcpy

Just a heads up: looks like std.mem.copy has been deprecated in favor of @memcpy builtin.

Here’s a commit that migrated some of the (?) calls to std.mem.copy to @memcpy - Remove all usages of `std.mem.copy` and remove `std.mem.set` (#18143) · ziglang/zig@1e42a3d · GitHub , could be useful as a model to follow.

Also, note that there is a difference between them - std.mem.copy was an alias for std.mem.copyForwards, which worked (and still works) for overlapping memory buffers. @memcpy, however, doesn’t relish the peach… I mean, overlapping buffers.

Old copy declaration:

/// Deprecated: use `@memcpy` if the arguments do not overlap, or
/// `copyForwards` if they do.
pub const copy = copyForwards;

Documentation on @memcpy:

Finally, the two memory regions must not overlap

Note that std.mem.copy has been deprecated since April 2023. The relevant context with a giant amount of examples of how code was updated:

Where the change was made:

Where tons of code was updated:


Yes, it was a poor choice of words on my part. I should have used " std.mem.copy has been removed in favor of @memcpy builtin and / or std.mem.copyForwards, of which it was an alias anyway".

I didn’t want to edit the post, probably should have.