✓
Passing This code compiles and runs correctly.
Code
import app/data
app/data:alloc(): a |> app/data:process(d: a)
Flows
flow ~alloc click a branch to expand · @labels scroll to their anchor
alloc
Imported Files
const std = @import("std");
const Data = struct { value: i32 };
~pub tor alloc {} -> *Data<owned>
~proc alloc|zig {
const allocator = std.heap.page_allocator;
const d = allocator.create(Data) catch unreachable;
d.* = Data{ .value = 42 };
return d;
}
~pub tor borrow { other: *Data<owned> } -> *Data<borrowed>
~proc borrow|zig {
return other;
}
// Generic processor that accepts data in ANY state and preserves it
~pub tor process { d: *Data<M'_> } -> *Data<M'_> // Wildcard: accepts any state, preserves it
~proc process|zig {
// Process the data without changing its state
return d;
}
// Generic processor that accepts data in ANY state and preserves it
const Data = struct { value: i32 };
~pub tor process { d: *Data<M'_> } -> *Data<M'_> // Wildcard: accepts any state, preserves it
~proc process|zig {
// Process the data without changing its state
return d;
}