Skip to content

Commit

Permalink
Fix: Don't use std.meta.trait (#263)
Browse files Browse the repository at this point in the history
std.meta.trait has been removed from standard library. Some functions
have moved to std.meta but others are simply gone ziglang/zig@d5e21a4
  • Loading branch information
robert3005 authored Nov 28, 2023
1 parent 384b9e1 commit 5935c5b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pydust/src/types/memoryview.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ pub const PyMemoryView = extern struct {

pub fn fromSlice(slice: anytype) !PyMemoryView {
const sliceType = Slice(@TypeOf(slice));
const flag = if (std.meta.trait.isConstPtr(sliceType)) PyMemoryView.Flags.PyBUF_READ else PyMemoryView.Flags.PyBUF_WRITE;
const sliceTpInfo = @typeInfo(sliceType);

const flag = if (sliceTpInfo == .Pointer and sliceTpInfo.Pointer.is_const) PyMemoryView.Flags.PyBUF_READ else PyMemoryView.Flags.PyBUF_WRITE;
return .{ .obj = .{
.py = py.ffi.PyMemoryView_FromMemory(@constCast(slice.ptr), @intCast(slice.len), flag) orelse return py.PyError.PyRaised,
} };
Expand Down

0 comments on commit 5935c5b

Please sign in to comment.