MemoryLayout<T>.offset for classes

Looking back this still feels strange despite of how it is explained in the docs and the comments in this topic (e.g. this is merely getting the offsets we are talking about here, e.g. to print them out; accessing fields via unsafe means is a different story altogether). Wouldn't it be reasonable if MemoryLayout<SomeClass>.offset(of: \.someField) was a compile-time error instead of returning nil at runtime?

1 Like