Updated type grammar #65

This commit is contained in:
2026-06-05 17:06:06 +02:00
parent 94320bafa6
commit 40b2981252
13 changed files with 5 additions and 823 deletions
-44
View File
@@ -1,44 +0,0 @@
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();
}