Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Allocator = @import("std").mem.Allocator;
- pub const Inner = struct {
- allocator: Allocator,
- inner_field: i32,
- };
- pub const Outer = struct {
- inner: Inner,
- outer_field: i32,
- pub fn init() Outer {
- return Outer{
- .inner = Inner{
- .allocator = Allocator{
- .allocFn = alloc,
- .reallocFn = realloc,
- .freeFn = free,
- },
- .inner_field = 200,
- },
- .outer_field = 100,
- };
- }
- fn alloc(allocator: *Allocator, n: usize, alignment: u29) ![]u8 {
- const inner = @fieldParentPtr(Inner, "allocator", allocator);
- const outer = @fieldParentPtr(Outer, "inner", inner);
- etc...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement