Merge pull request #18590 from paldepind/rust-control-flow-test

Rust: Add two additional control flow tests
This commit is contained in:
Simon Friis Vindum
2025-01-27 09:05:20 +01:00
committed by GitHub
3 changed files with 2458 additions and 2303 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -134,6 +134,14 @@ mod if_expression {
}
}
fn test_if_without_else(b: bool) -> i64 {
let mut i = 3;
if b {
i += 1;
}
i
}
fn test_if_let_else(a: Option<i64>) -> i64 {
if let Some(n) = a {
n
@@ -157,6 +165,17 @@ mod if_expression {
}
}
fn test_nested_if_2(cond1: bool, cond2: bool) -> () {
if cond1 {
if cond2 {
println!("1");
} else {
println!("2");
}
println!("3");
};
}
fn test_nested_if_match(a: i64) -> i64 {
if (match a {
0 => true,