diff options
Diffstat (limited to 'gcc/testsuite/rust/compile/iflet.rs')
-rw-r--r-- | gcc/testsuite/rust/compile/iflet.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/iflet.rs b/gcc/testsuite/rust/compile/iflet.rs new file mode 100644 index 0000000..6d46339 --- /dev/null +++ b/gcc/testsuite/rust/compile/iflet.rs @@ -0,0 +1,32 @@ +pub fn simple_iflet() -> i32 { + let mut res = 0; + + enum E { + X(i32), + } + let v = E::X(4); + + if let E::X(n) = v { + res = 1; + } + + res +} + +pub fn simple_iflet_else() -> i32 { + let mut res = 0; + + enum E { + X(i32), + Y, + } + let v = E::X(4); + + if let E::Y = v { + res = 1; + } else { + res = 2; + } + + res +} |