struct Point { x i32, y i32, } pub fn test_struct_create_access() { let p = Point { x: 10, y: 20 }; assert_eq!(p.x, 10); assert_eq!(p.y, 20); } pub fn test_struct_mut_field() { let mut p = Point { x: 1, y: 2 }; p.x = 100; assert_eq!(p.x, 100); } pub fn 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 { start Point, end Point, } pub fn 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 fn run_tests() { test_struct_create_access(); test_struct_mut_field(); test_struct_destructure(); test_struct_nested(); }