Here's a simple solution. Just make Bar a pointer and free it before it can be destructed!

import std.stdio;

struct Bar {
    ~this() {
        writeln("~bar");
    }
}

struct Foo {
    Bar *bar;
this(int why_the_fuck_dont_structs_have_default_constructors) {
        bar = new Bar;
    }
    ~this() {
        writeln("~foo");
        import core.memory;
        GC.free(bar);
    }
}

Reply via email to