chore: update to latest builtin syntax

This commit is contained in:
Rekai Nyangadzayi Musuka 2023-07-10 21:55:21 -05:00
parent e616cf09e5
commit 322c798e38
1 changed files with 7 additions and 7 deletions

View File

@ -101,7 +101,7 @@ pub fn Channel(comptime T: type, comptime N: usize) type {
}; };
fn mask(idx: Index) Index { fn mask(idx: Index) Index {
return idx & (@intCast(Index, N) - 1); return idx & (@as(Index, @intCast(N)) - 1);
} }
pub fn init(allocator: Allocator) !Channel(T, N) { pub fn init(allocator: Allocator) !Channel(T, N) {
@ -123,9 +123,9 @@ pub fn Channel(comptime T: type, comptime N: usize) type {
} }
pub fn deinit(self: *Channel(T, N), allocator: Allocator) void { pub fn deinit(self: *Channel(T, N), allocator: Allocator) void {
const indicies: []Index = @ptrCast([*]Index, self.tx.read)[0..2]; const indicies: [*]Index = @ptrCast(self.tx.read);
allocator.free(indicies); allocator.free(indicies[0..2]);
allocator.free(self.tx.ptr); allocator.free(self.tx.ptr);
self.* = undefined; self.* = undefined;
@ -221,7 +221,7 @@ pub fn RingBuffer(comptime T: type) type {
/// Returns the number of entries read /// Returns the number of entries read
pub fn copy(self: *const Self, cpy: []T) Index { pub fn copy(self: *const Self, cpy: []T) Index {
const count = std.math.min(self.len(), cpy.len); const count = @min(self.len(), cpy.len);
var start: Index = self.read; var start: Index = self.read;
for (cpy, 0..) |*v, i| { for (cpy, 0..) |*v, i| {
@ -259,9 +259,9 @@ pub fn sext(comptime T: type, comptime U: type, value: T) T {
const iT = std.meta.Int(.signed, @typeInfo(T).Int.bits); const iT = std.meta.Int(.signed, @typeInfo(T).Int.bits);
const ExtU = if (@typeInfo(U).Int.signedness == .unsigned) T else iT; const ExtU = if (@typeInfo(U).Int.signedness == .unsigned) T else iT;
const shift_amt = @intCast(Log2Int(T), @typeInfo(T).Int.bits - @typeInfo(U).Int.bits); const shift_amt: Log2Int(T) = @intCast(@typeInfo(T).Int.bits - @typeInfo(U).Int.bits);
return @bitCast(T, @bitCast(iT, @as(ExtU, @truncate(U, value)) << shift_amt) >> shift_amt); return @bitCast(@as(iT, @bitCast(@as(ExtU, @as(U, @truncate(value))) << shift_amt)) >> shift_amt);
} }
/// See https://godbolt.org/z/W3en9Eche /// See https://godbolt.org/z/W3en9Eche
@ -269,6 +269,6 @@ pub inline fn rotr(comptime T: type, x: T, r: anytype) T {
if (@typeInfo(T).Int.signedness == .signed) if (@typeInfo(T).Int.signedness == .signed)
@compileError("cannot rotate signed integer"); @compileError("cannot rotate signed integer");
const ar = @intCast(Log2Int(T), @mod(r, @typeInfo(T).Int.bits)); const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits));
return x >> ar | x << (1 +% ~ar); return x >> ar | x << (1 +% ~ar);
} }