change semantics of @memcpy and @memset

Now they use slices or array pointers with any element type instead of
requiring byte pointers.

This is a breaking enhancement to the language.

The safety check for overlapping pointers will be implemented in a
future commit.

closes #14040
This commit is contained in:
Andrew Kelley
2023-04-13 21:44:40 -07:00
parent 8d88dcdc61
commit a5c910adb6
33 changed files with 220 additions and 279 deletions

View File

@@ -367,8 +367,8 @@ fn testMemcpyMemset() !void {
var foo: [20]u8 = undefined;
var bar: [20]u8 = undefined;
@memset(&foo, 'A', foo.len);
@memcpy(&bar, &foo, bar.len);
@memset(&foo, 'A');
@memcpy(&bar, &foo);
try expect(bar[0] == 'A');
try expect(bar[11] == 'A');