In my codebase I end up running a lot in the following pattern:
pub const A = struct {
child: B,
}
pub const B = struct {
parent: *A,
}
is there an elegant way to initialize both strucutres (preferably B first and then A) or is my design just bad? at the moment i have something similar to:
pub const B = struct {
parent: ?*A = null,
}
so that i can initialize b, pass it to a on creation and then set it's parent, but i dont think this is the best way to do it and i also have to deal with the null checks every time.