The idea is to deliberately mark @system functions that need special scrutiny to use, regardless of their memory-safety. Function that would typically be named `assumeXXX`.


```d
class MyEncodedThing
{
    Encoding encoding;

    /// Unsafe cast of encoding.
void assumeEncoding (Encoding encoding) /* here */ @system /* here */
    {
        this.encoding = encoding;
    }
}

char* assumeZeroTerminated(char[] str) @system
{
    return str.ptr;
}

```

That way, @safe code will still need to manually @trust them.


  • Cool pattern or ... Guillaume Piolat via Digitalmars-d-learn

Reply via email to