When using an allocator to create a new instance of something, this instance is undefined
thus possibly in an invalid state. I suspect its tag is simply neither small
nor large
but an illegal value.
When you access the small
variant with new_struct.small.init(data)
your program panic in debug and safe mode. You should set the variant before:
new_struct.* = .{ .small = undefined };
new_struct.small.init(data);