// growable arrays and fixed ones struct point { int x, y; }; fn main() { let before = live_objects(); { []int a = new([]int); for (int i = 0; i < 100; i++) push(a, i * i); put_n(len(a)); put_c(' '); put_n(cap(a)); put_c(' '); put_n(a[99]); put_c(' '); put_n(pop(a)); put_c(' '); put_n(len(a)); put_c(' '); resize(a, 3); put_n(len(a)); put_c(' '); put_n(a[2]); put_c(' '); fixed []int f = new(fixed []int, 5); f[4] = 7; put_n(f[4] + len(f)); put_c(' '); []point ps = new([]point, 2); ps[1].y = 9; resize(ps, 10); put_n(ps[1].y + len(ps)); put_c(' '); [8]int st; put_n(len(st)); put_c(' '); []point* owned = new([]point*); for (int i = 0; i < 20; i++) { point* p = new(point); p.x = i; push(owned, d*p); } put_n(owned[19].x); put_c(' '); put_n(live_objects() - before); put_c(10); } put_n(live_objects() - before); put_c(10); return 0; }