Is this safe? class A {} immutable(A) getA() { A a; // .. do stuff with a // not leaking a to any functions
// is this safe???? return cast(immutable A)a; } What if A is replaced with A[] or A[int]?If it's not safe, what would be the proper way to return an immutable instance from a function which needs to make adjustments to the instance before returning it as immutable?