Why does a variable UInt8 in a swift struct show an offset of 2? However a struct of just UInt8s shows an offset of 1?
struct Test {
let a: UInt8
let b: UInt16
}
MemoryLayout<Test>.offset(of: \Test.a) // 0
MemoryLayout<Test>.offset(of: \Test.b) // 2 (not 1)
struct Test2 {
let a: UInt8
let b: UInt8
let c: UInt8
}
MemoryLayout<Test2>.offset(of: \Test2.a) // 0
MemoryLayout<Test2>.offset(of: \Test2.b) // 1
MemoryLayout<Test2>.offset(of: \Test2.c) // 2