On Friday, 8 April 2022 at 05:53:03 UTC, Elvis Zhou wrote:

assumeNoEscapeOrWhatever!DynamicArray structs;
structs ~= cast(A*)&b;

is it possible?

That's what `@trusted` is for. And that's also why it should be used with care, and on the smallest code possible.

```d
struct A {}
struct B { A a; }
struct C { A a; }

void main()
{
    A*[] structs;

    B b;
    C c;

    () @trusted {
        structs ~= cast(A*)&b;
        structs ~= cast(A*)&c;
    } ();
}
```

Reply via email to