If a function is marked @safe, casting away immutable is
not allowed by the compiler.
But, you can't put this on the array. It needs to be on
the user's functions:
@safe void foo(immutable(ubyte)[] arr) {
auto cheating = cast(ubyte[]) arr;
}
test2.d(2): Error: cast from immutable(ubyte)[] to ubyte[] not
allowed in safe code