File tree Expand file tree Collapse file tree 3 files changed +59
-2
lines changed
test/src/e2e_vm_tests/test_programs/should_pass/language/match_expressions_rest Expand file tree Collapse file tree 3 files changed +59
-2
lines changed Original file line number Diff line number Diff line change 1+ [[package]]
2+ name = 'core'
3+ source = 'path+from-root-8F0E3A0B953247F5'
4+ dependencies = []
5+
16[[package]]
27name = 'match_expressions_rest'
38source = 'root'
4- dependencies = []
9+ dependencies = ['std']
10+
11+ [[package]]
12+ name = 'std'
13+ source = 'git+https://github.com/fuellabs/sway?tag=v0.16.0#948f7aba42b4138433fb5b61c698c8f4a60db424'
14+ dependencies = ['core']
Original file line number Diff line number Diff line change 33license = " Apache-2.0"
44name = " match_expressions_rest"
55entry = " main.sw"
6- implicit-std = false
6+ implicit-std = true
Original file line number Diff line number Diff line change @@ -5,6 +5,23 @@ struct Point {
55 y : u64
66}
77
8+ struct Point3D {
9+ x : u64 ,
10+ y : u64 ,
11+ z : u64
12+ }
13+
14+ struct Line {
15+ p1 : Point ,
16+ p2 : Point
17+ }
18+
19+ enum Kind {
20+ Point : Point ,
21+ Point3D : Point3D ,
22+ Line : Line
23+ }
24+
825fn main () -> u64 {
926 let p = Point {
1027 x : 1u64 ,
@@ -15,5 +32,35 @@ fn main() -> u64 {
1532 Point { x , .. } => { x },
1633 };
1734
35+ let p2 = Point3D {
36+ x : 1u64 ,
37+ y : 2u64 ,
38+ z : 3u64 ,
39+ };
40+
41+ match p2 {
42+ Point3D { x , .. } => { x },
43+ };
44+
45+ let l = Line { p1 : p , p2 : p };
46+
47+ match l {
48+ Line { p1 , .. } => {}
49+ }
50+
51+ match l {
52+ Line { p1 : Point { .. }, p2 : Point { .. } } => {}
53+ }
54+
55+ let k = Kind :: Point (p );
56+
57+ match k {
58+ Kind :: Point (Point { x , .. }) => {},
59+ Kind :: Point3D (Point3D { z , .. }) => {},
60+ Kind :: Line (Line { p1 : Point { .. }, p2 : Point { .. } }) => {},
61+ }
62+
63+ let a = [p , p ];
64+
1865 0
1966}
You can’t perform that action at this time.
0 commit comments