| ... | ... | @@ -192,7 +192,8 @@ test "Allocator.resize" { |
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | | /// Deprecated: use `copyForwards` |
| 195 | /// Deprecated: use `@memcpy` if the arguments do not overlap, or |
| 196 | /// `copyForwards` if they do. |
| 196 | 197 | pub const copy = copyForwards; |
| 197 | 198 | |
| 198 | 199 | /// Copy all of source into dest at position 0. |
| ... | ... | @@ -218,11 +219,7 @@ pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void { |
| 218 | 219 | } |
| 219 | 220 | } |
| 220 | 221 | |
| 221 | | /// Sets all elements of `dest` to `value`. |
| 222 | | pub fn set(comptime T: type, dest: []T, value: T) void { |
| 223 | | for (dest) |*d| |
| 224 | | d.* = value; |
| 225 | | } |
| 222 | pub const set = @compileError("deprecated; use @memset instead"); |
| 226 | 223 | |
| 227 | 224 | /// Generally, Zig users are encouraged to explicitly initialize all fields of a struct explicitly rather than using this function. |
| 228 | 225 | /// However, it is recognized that there are sometimes use cases for initializing all fields to a "zero" value. For example, when |
| ... | ... | @@ -251,7 +248,7 @@ pub fn zeroes(comptime T: type) T { |
| 251 | 248 | if (@sizeOf(T) == 0) return undefined; |
| 252 | 249 | if (struct_info.layout == .Extern) { |
| 253 | 250 | var item: T = undefined; |
| 254 | | set(u8, asBytes(&item), 0); |
| 251 | @memset(asBytes(&item), 0); |
| 255 | 252 | return item; |
| 256 | 253 | } else { |
| 257 | 254 | var structure: T = undefined; |
| ... | ... | @@ -1669,9 +1666,9 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void { |
| 1669 | 1666 | assert(buffer.len >= @divExact(@typeInfo(T).Int.bits, 8)); |
| 1670 | 1667 | |
| 1671 | 1668 | if (@typeInfo(T).Int.bits == 0) { |
| 1672 | | return set(u8, buffer, 0); |
| 1669 | return @memset(buffer, 0); |
| 1673 | 1670 | } else if (@typeInfo(T).Int.bits == 8) { |
| 1674 | | set(u8, buffer, 0); |
| 1671 | @memset(buffer, 0); |
| 1675 | 1672 | buffer[0] = @bitCast(u8, value); |
| 1676 | 1673 | return; |
| 1677 | 1674 | } |
| ... | ... | @@ -1693,9 +1690,9 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void { |
| 1693 | 1690 | assert(buffer.len >= @divExact(@typeInfo(T).Int.bits, 8)); |
| 1694 | 1691 | |
| 1695 | 1692 | if (@typeInfo(T).Int.bits == 0) { |
| 1696 | | return set(u8, buffer, 0); |
| 1693 | return @memset(buffer, 0); |
| 1697 | 1694 | } else if (@typeInfo(T).Int.bits == 8) { |
| 1698 | | set(u8, buffer, 0); |
| 1695 | @memset(buffer, 0); |
| 1699 | 1696 | buffer[buffer.len - 1] = @bitCast(u8, value); |
| 1700 | 1697 | return; |
| 1701 | 1698 | } |
| ... | ... | @@ -2708,7 +2705,7 @@ fn testReadIntImpl() !void { |
| 2708 | 2705 | } |
| 2709 | 2706 | } |
| 2710 | 2707 | |
| 2711 | | test "writeIntSlice" { |
| 2708 | test writeIntSlice { |
| 2712 | 2709 | try testWriteIntImpl(); |
| 2713 | 2710 | comptime try testWriteIntImpl(); |
| 2714 | 2711 | } |