stage1 重构代码
This commit is contained in:
@@ -253,13 +253,13 @@ fn test_enum_complex() i32 {
|
||||
|
||||
/* Verify active variant */
|
||||
match s {
|
||||
.Active(val) => {
|
||||
.Active[val] => {
|
||||
if val != 42 { ret 1; }
|
||||
},
|
||||
.Inactive => {
|
||||
ret 2;
|
||||
},
|
||||
.Pending(px, py) => {
|
||||
.Pending[.x = px, .y = py] => {
|
||||
ret 3;
|
||||
}
|
||||
}
|
||||
@@ -268,18 +268,18 @@ fn test_enum_complex() i32 {
|
||||
var s2: Status = Status { .Inactive };
|
||||
var is_inactive: i32 = 0;
|
||||
match s2 {
|
||||
.Active(val) => {},
|
||||
.Active[val] => {},
|
||||
.Inactive => { is_inactive = 1; },
|
||||
.Pending(px, py) => {}
|
||||
.Pending[.x = px, .y = py] => {}
|
||||
}
|
||||
if is_inactive != 1 { ret 4; }
|
||||
|
||||
/* Test Pending variant with struct data */
|
||||
var s3: Status = Status { .Pending = Point { .x = 7, .y = 8 } };
|
||||
match s3 {
|
||||
.Active(val) => { ret 5; },
|
||||
.Active[val] => { ret 5; },
|
||||
.Inactive => { ret 6; },
|
||||
.Pending(px, py) => {
|
||||
.Pending[.x = px, .y = py] => {
|
||||
if px != 7 { ret 7; }
|
||||
if py != 8 { ret 8; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user