pub module struct_test; struct Point { i32 x, i32 y, } pub void test_struct_create_access() { let p = Point { x: 10, y: 20, }; assert_eq!(p.x, 10); assert_eq!(p.y, 20); } pub void test_struct_mut_field() { let mut p = Point { x: 1, y: 2, }; p.x = 100; assert_eq!(p.x, 100); } pub void test_struct_destructure() { let p = Point { x: 3, y: 4, }; let Point {x, y} = p; assert_eq!(x, 3); assert_eq!(y, 4); } struct Line { Point start, Point end, } pub void test_struct_nested() { let l = Line { start: Point { x: 0, y: 0, }, end: Point { x: 5, y: 10, }, }; assert_eq!(l.start.x, 0); assert_eq!(l.end.y, 10); } pub void run_tests() { test_struct_create_access(); test_struct_mut_field(); test_struct_destructure(); test_struct_nested(); }