Moon values and C layouts

An ordinary Moon struct has value semantics. Giving its fields C-like widths does not assert a C ABI or packed representation. @C and @packed are retired.

Foreign records take their size, alignment, field offsets and packing from the imported C declaration. Their imported names are used directly as values. Source-level header loading is still unavailable in the current runner, so this example demonstrates an ordinary Moon value only.

Do not substitute this struct for a C record merely because its fields look alike.

struct Point { x: i32, y: i32 }

fn main() {
  let point = Point { x: 3, y: 4 }
  let copy = point
}
Run locally
moon check main.mn
Ctrl/⌘+Enter checks the current lesson.