diff --git a/src/lib.zig b/src/lib.zig index 958782c..69d7b97 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -101,7 +101,7 @@ pub fn Channel(comptime T: type, comptime N: usize) type { }; 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) { @@ -123,9 +123,9 @@ pub fn Channel(comptime T: type, comptime N: usize) type { } 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); self.* = undefined; @@ -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 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 @@ -269,6 +269,6 @@ pub inline fn rotr(comptime T: type, x: T, r: anytype) T { if (@typeInfo(T).Int.signedness == .signed) @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); }