master
 1const Point = struct {
 2    x: i32,
 3    y: i32,
 4};
 5
 6fn foo(point: Point) i32 {
 7    // Here, `point` could be a reference, or a copy. The function body
 8    // can ignore the difference and treat it as a value. Be very careful
 9    // taking the address of the parameter - it should be treated as if
10    // the address will become invalid when the function returns.
11    return point.x + point.y;
12}
13
14const expect = @import("std").testing.expect;
15
16test "pass struct to function" {
17    try expect(foo(Point{ .x = 1, .y = 2 }) == 3);
18}
19
20// test