✓
Passing This code compiles and runs correctly.
Code
~import "$app/data"
~app.data:alloc()
| allocated a |> app.data:process(d: a)
| done _ |> _
Imported Files
const std = @import("std");
const Data = struct { value: i32 };
~pub event alloc {}
| allocated *Data[owned]
~proc alloc {
const allocator = std.heap.page_allocator;
const d = allocator.create(Data) catch unreachable;
d.* = Data{ .value = 42 };
return .{ .allocated = d };
}
~pub event borrow { other: *Data[owned] }
| borrowed *Data[borrowed]
~proc borrow {
return .{ .borrowed = other };
}
// Generic processor that accepts data in ANY state and preserves it
~pub event process { d: *Data[M'_] }
| done *Data[M'_] // Wildcard: accepts any state, preserves it
~proc process {
// Process the data without changing its state
return .{ .done = d };
}
// Generic processor that accepts data in ANY state and preserves it
const Data = struct { value: i32 };
~pub event process { d: *Data[M'_] }
| done *Data[M'_] // Wildcard: accepts any state, preserves it
~proc process {
// Process the data without changing its state
return .{ .done = d };
}