Field Lifetime of Heap-Allocated Struct

Correct me if I’m wrong, .left = Node{ .atom = 0 } here has a static lifetime so problem solved.

Here’s the declaration.

const Node = union(enum) {
    atom: u8,
    cons: struct {
        op: u8,
        left: *const Node,
        right: *const Node,
    },
}
1 Like