Use standard style for test code

This commit is contained in:
Aleksey Kladov 2020-11-09 13:28:04 +01:00
parent 3cecf78488
commit d31ce3b16c

View file

@ -281,14 +281,18 @@ mod tests {
fn wrap_return_type_in_result_simple() { fn wrap_return_type_in_result_simple() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i3<|>2 { r#"
fn foo() -> i3<|>2 {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
return Ok(42i32); return Ok(42i32);
}"#, }
"#,
); );
} }
@ -296,18 +300,22 @@ mod tests {
fn wrap_return_type_in_result_simple_closure() { fn wrap_return_type_in_result_simple_closure() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() { r#"
fn foo() {
|| -> i32<|> { || -> i32<|> {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}; };
}"#, }
r#"fn foo() { "#,
r#"
fn foo() {
|| -> Result<i32, ${0:_}> { || -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
return Ok(42i32); return Ok(42i32);
}; };
}"#, }
"#,
); );
} }
@ -315,10 +323,12 @@ mod tests {
fn wrap_return_type_in_result_simple_return_type_bad_cursor() { fn wrap_return_type_in_result_simple_return_type_bad_cursor() {
check_assist_not_applicable( check_assist_not_applicable(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32 { r#"
fn foo() -> i32 {
let test = "test";<|> let test = "test";<|>
return 42i32; return 42i32;
}"#, }
"#,
); );
} }
@ -326,33 +336,32 @@ mod tests {
fn wrap_return_type_in_result_simple_return_type_bad_cursor_closure() { fn wrap_return_type_in_result_simple_return_type_bad_cursor_closure() {
check_assist_not_applicable( check_assist_not_applicable(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() { r#"
fn foo() {
|| -> i32 { || -> i32 {
let test = "test";<|> let test = "test";<|>
return 42i32; return 42i32;
}; };
}"#, }
"#,
); );
} }
#[test] #[test]
fn wrap_return_type_in_result_closure_non_block() { fn wrap_return_type_in_result_closure_non_block() {
check_assist_not_applicable( check_assist_not_applicable(wrap_return_type_in_result, r#"fn foo() { || -> i<|>32 3; }"#);
wrap_return_type_in_result,
r#"fn foo() {
|| -> i<|>32 3;
}"#,
);
} }
#[test] #[test]
fn wrap_return_type_in_result_simple_return_type_already_result_std() { fn wrap_return_type_in_result_simple_return_type_already_result_std() {
check_assist_not_applicable( check_assist_not_applicable(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> std::result::Result<i32<|>, String> { r#"
fn foo() -> std::result::Result<i32<|>, String> {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}"#, }
"#,
); );
} }
@ -361,10 +370,12 @@ mod tests {
mark::check!(wrap_return_type_in_result_simple_return_type_already_result); mark::check!(wrap_return_type_in_result_simple_return_type_already_result);
check_assist_not_applicable( check_assist_not_applicable(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> Result<i32<|>, String> { r#"
fn foo() -> Result<i32<|>, String> {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}"#, }
"#,
); );
} }
@ -372,12 +383,14 @@ mod tests {
fn wrap_return_type_in_result_simple_return_type_already_result_closure() { fn wrap_return_type_in_result_simple_return_type_already_result_closure() {
check_assist_not_applicable( check_assist_not_applicable(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() { r#"
fn foo() {
|| -> Result<i32<|>, String> { || -> Result<i32<|>, String> {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}; };
}"#, }
"#,
); );
} }
@ -385,14 +398,18 @@ mod tests {
fn wrap_return_type_in_result_simple_with_cursor() { fn wrap_return_type_in_result_simple_with_cursor() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> <|>i32 { r#"
fn foo() -> <|>i32 {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
return Ok(42i32); return Ok(42i32);
}"#, }
"#,
); );
} }
@ -400,14 +417,18 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail() { fn wrap_return_type_in_result_simple_with_tail() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -><|> i32 { r#"
fn foo() -><|> i32 {
let test = "test"; let test = "test";
42i32 42i32
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
Ok(42i32) Ok(42i32)
}"#, }
"#,
); );
} }
@ -415,18 +436,22 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail_closure() { fn wrap_return_type_in_result_simple_with_tail_closure() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() { r#"
fn foo() {
|| -><|> i32 { || -><|> i32 {
let test = "test"; let test = "test";
42i32 42i32
}; };
}"#, }
r#"fn foo() { "#,
r#"
fn foo() {
|| -> Result<i32, ${0:_}> { || -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
Ok(42i32) Ok(42i32)
}; };
}"#, }
"#,
); );
} }
@ -434,12 +459,8 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail_only() { fn wrap_return_type_in_result_simple_with_tail_only() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"fn foo() -> i32<|> { 42i32 }"#,
42i32 r#"fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }"#,
}"#,
r#"fn foo() -> Result<i32, ${0:_}> {
Ok(42i32)
}"#,
); );
} }
@ -447,20 +468,24 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail_block_like() { fn wrap_return_type_in_result_simple_with_tail_block_like() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
if true { if true {
42i32 42i32
} else { } else {
24i32 24i32
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
if true { if true {
Ok(42i32) Ok(42i32)
} else { } else {
Ok(24i32) Ok(24i32)
} }
}"#, }
"#,
); );
} }
@ -468,7 +493,8 @@ mod tests {
fn wrap_return_type_in_result_simple_without_block_closure() { fn wrap_return_type_in_result_simple_without_block_closure() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() { r#"
fn foo() {
|| -> i32<|> { || -> i32<|> {
if true { if true {
42i32 42i32
@ -476,8 +502,10 @@ mod tests {
24i32 24i32
} }
}; };
}"#, }
r#"fn foo() { "#,
r#"
fn foo() {
|| -> Result<i32, ${0:_}> { || -> Result<i32, ${0:_}> {
if true { if true {
Ok(42i32) Ok(42i32)
@ -485,7 +513,8 @@ mod tests {
Ok(24i32) Ok(24i32)
} }
}; };
}"#, }
"#,
); );
} }
@ -493,7 +522,8 @@ mod tests {
fn wrap_return_type_in_result_simple_with_nested_if() { fn wrap_return_type_in_result_simple_with_nested_if() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
if true { if true {
if false { if false {
1 1
@ -503,8 +533,10 @@ mod tests {
} else { } else {
24i32 24i32
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
if true { if true {
if false { if false {
Ok(1) Ok(1)
@ -514,7 +546,8 @@ mod tests {
} else { } else {
Ok(24i32) Ok(24i32)
} }
}"#, }
"#,
); );
} }
@ -522,7 +555,8 @@ mod tests {
fn wrap_return_type_in_result_simple_with_await() { fn wrap_return_type_in_result_simple_with_await() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"async fn foo() -> i<|>32 { r#"
async fn foo() -> i<|>32 {
if true { if true {
if false { if false {
1.await 1.await
@ -532,8 +566,10 @@ mod tests {
} else { } else {
24i32.await 24i32.await
} }
}"#, }
r#"async fn foo() -> Result<i32, ${0:_}> { "#,
r#"
async fn foo() -> Result<i32, ${0:_}> {
if true { if true {
if false { if false {
Ok(1.await) Ok(1.await)
@ -543,7 +579,8 @@ mod tests {
} else { } else {
Ok(24i32.await) Ok(24i32.await)
} }
}"#, }
"#,
); );
} }
@ -551,12 +588,8 @@ mod tests {
fn wrap_return_type_in_result_simple_with_array() { fn wrap_return_type_in_result_simple_with_array() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> [i32;<|> 3] { r#"fn foo() -> [i32;<|> 3] { [1, 2, 3] }"#,
[1, 2, 3] r#"fn foo() -> Result<[i32; 3], ${0:_}> { Ok([1, 2, 3]) }"#,
}"#,
r#"fn foo() -> Result<[i32; 3], ${0:_}> {
Ok([1, 2, 3])
}"#,
); );
} }
@ -564,7 +597,8 @@ mod tests {
fn wrap_return_type_in_result_simple_with_cast() { fn wrap_return_type_in_result_simple_with_cast() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -<|>> i32 { r#"
fn foo() -<|>> i32 {
if true { if true {
if false { if false {
1 as i32 1 as i32
@ -574,8 +608,10 @@ mod tests {
} else { } else {
24 as i32 24 as i32
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
if true { if true {
if false { if false {
Ok(1 as i32) Ok(1 as i32)
@ -585,7 +621,8 @@ mod tests {
} else { } else {
Ok(24 as i32) Ok(24 as i32)
} }
}"#, }
"#,
); );
} }
@ -593,20 +630,24 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail_block_like_match() { fn wrap_return_type_in_result_simple_with_tail_block_like_match() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let my_var = 5; let my_var = 5;
match my_var { match my_var {
5 => 42i32, 5 => 42i32,
_ => 24i32, _ => 24i32,
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let my_var = 5; let my_var = 5;
match my_var { match my_var {
5 => Ok(42i32), 5 => Ok(42i32),
_ => Ok(24i32), _ => Ok(24i32),
} }
}"#, }
"#,
); );
} }
@ -614,24 +655,26 @@ mod tests {
fn wrap_return_type_in_result_simple_with_loop_with_tail() { fn wrap_return_type_in_result_simple_with_loop_with_tail() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let my_var = 5; let my_var = 5;
loop { loop {
println!("test"); println!("test");
5 5
} }
my_var my_var
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let my_var = 5; let my_var = 5;
loop { loop {
println!("test"); println!("test");
5 5
} }
Ok(my_var) Ok(my_var)
}"#, }
"#,
); );
} }
@ -639,20 +682,22 @@ mod tests {
fn wrap_return_type_in_result_simple_with_loop_in_let_stmt() { fn wrap_return_type_in_result_simple_with_loop_in_let_stmt() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let my_var = let x = loop { let my_var = let x = loop {
break 1; break 1;
}; };
my_var my_var
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let my_var = let x = loop { let my_var = let x = loop {
break 1; break 1;
}; };
Ok(my_var) Ok(my_var)
}"#, }
"#,
); );
} }
@ -660,48 +705,52 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail_block_like_match_return_expr() { fn wrap_return_type_in_result_simple_with_tail_block_like_match_return_expr() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let my_var = 5; let my_var = 5;
let res = match my_var { let res = match my_var {
5 => 42i32, 5 => 42i32,
_ => return 24i32, _ => return 24i32,
}; };
res res
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let my_var = 5; let my_var = 5;
let res = match my_var { let res = match my_var {
5 => 42i32, 5 => 42i32,
_ => return Ok(24i32), _ => return Ok(24i32),
}; };
Ok(res) Ok(res)
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let my_var = 5; let my_var = 5;
let res = if my_var == 5 { let res = if my_var == 5 {
42i32 42i32
} else { } else {
return 24i32; return 24i32;
}; };
res res
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let my_var = 5; let my_var = 5;
let res = if my_var == 5 { let res = if my_var == 5 {
42i32 42i32
} else { } else {
return Ok(24i32); return Ok(24i32);
}; };
Ok(res) Ok(res)
}"#, }
"#,
); );
} }
@ -709,7 +758,8 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail_block_like_match_deeper() { fn wrap_return_type_in_result_simple_with_tail_block_like_match_deeper() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let my_var = 5; let my_var = 5;
match my_var { match my_var {
5 => { 5 => {
@ -727,8 +777,10 @@ mod tests {
53i32 53i32
}, },
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let my_var = 5; let my_var = 5;
match my_var { match my_var {
5 => { 5 => {
@ -746,7 +798,8 @@ mod tests {
Ok(53i32) Ok(53i32)
}, },
} }
}"#, }
"#,
); );
} }
@ -754,20 +807,24 @@ mod tests {
fn wrap_return_type_in_result_simple_with_tail_block_like_early_return() { fn wrap_return_type_in_result_simple_with_tail_block_like_early_return() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i<|>32 { r#"
fn foo() -> i<|>32 {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return 24i32; return 24i32;
} }
53i32 53i32
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return Ok(24i32); return Ok(24i32);
} }
Ok(53i32) Ok(53i32)
}"#, }
"#,
); );
} }
@ -775,45 +832,40 @@ mod tests {
fn wrap_return_type_in_result_simple_with_closure() { fn wrap_return_type_in_result_simple_with_closure() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo(the_field: u32) -><|> u32 { r#"
let true_closure = || { fn foo(the_field: u32) -><|> u32 {
return true; let true_closure = || { return true; };
};
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if true_closure() { if true_closure() {
return 99; return 99;
} else { } else {
return 0; return 0;
} }
} }
the_field the_field
}"#, }
r#"fn foo(the_field: u32) -> Result<u32, ${0:_}> { "#,
let true_closure = || { r#"
return true; fn foo(the_field: u32) -> Result<u32, ${0:_}> {
}; let true_closure = || { return true; };
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if true_closure() { if true_closure() {
return Ok(99); return Ok(99);
} else { } else {
return Ok(0); return Ok(0);
} }
} }
Ok(the_field) Ok(the_field)
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo(the_field: u32) -> u32<|> { r#"
fn foo(the_field: u32) -> u32<|> {
let true_closure = || { let true_closure = || {
return true; return true;
}; };
@ -830,8 +882,10 @@ mod tests {
let t = None; let t = None;
t.unwrap_or_else(|| the_field) t.unwrap_or_else(|| the_field)
}"#, }
r#"fn foo(the_field: u32) -> Result<u32, ${0:_}> { "#,
r#"
fn foo(the_field: u32) -> Result<u32, ${0:_}> {
let true_closure = || { let true_closure = || {
return true; return true;
}; };
@ -848,7 +902,8 @@ mod tests {
let t = None; let t = None;
Ok(t.unwrap_or_else(|| the_field)) Ok(t.unwrap_or_else(|| the_field))
}"#, }
"#,
); );
} }
@ -856,7 +911,8 @@ mod tests {
fn wrap_return_type_in_result_simple_with_weird_forms() { fn wrap_return_type_in_result_simple_with_weird_forms() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return 24i32; return 24i32;
@ -868,8 +924,10 @@ mod tests {
} }
i += 1; i += 1;
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return Ok(24i32); return Ok(24i32);
@ -881,12 +939,14 @@ mod tests {
} }
i += 1; i += 1;
} }
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { r#"
fn foo() -> i32<|> {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return 24i32; return 24i32;
@ -900,8 +960,10 @@ mod tests {
i += 1; i += 1;
} }
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return Ok(24i32); return Ok(24i32);
@ -915,12 +977,14 @@ mod tests {
i += 1; i += 1;
} }
} }
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i3<|>2 { r#"
fn foo() -> i3<|>2 {
let test = "test"; let test = "test";
let other = 5; let other = 5;
if test == "test" { if test == "test" {
@ -938,8 +1002,10 @@ mod tests {
i += 1; i += 1;
} }
} }
}"#, }
r#"fn foo() -> Result<i32, ${0:_}> { "#,
r#"
fn foo() -> Result<i32, ${0:_}> {
let test = "test"; let test = "test";
let other = 5; let other = 5;
if test == "test" { if test == "test" {
@ -957,12 +1023,14 @@ mod tests {
i += 1; i += 1;
} }
} }
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo(the_field: u32) -> u32<|> { r#"
fn foo(the_field: u32) -> u32<|> {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
loop { loop {
@ -971,16 +1039,16 @@ mod tests {
} }
i += 3; i += 3;
} }
match i { match i {
5 => return 99, 5 => return 99,
_ => return 0, _ => return 0,
}; };
} }
the_field the_field
}"#, }
r#"fn foo(the_field: u32) -> Result<u32, ${0:_}> { "#,
r#"
fn foo(the_field: u32) -> Result<u32, ${0:_}> {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
loop { loop {
@ -989,103 +1057,102 @@ mod tests {
} }
i += 3; i += 3;
} }
match i { match i {
5 => return Ok(99), 5 => return Ok(99),
_ => return Ok(0), _ => return Ok(0),
}; };
} }
Ok(the_field) Ok(the_field)
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo(the_field: u32) -> u3<|>2 { r#"
fn foo(the_field: u32) -> u3<|>2 {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
match i { match i {
5 => return 99, 5 => return 99,
_ => return 0, _ => return 0,
} }
} }
the_field the_field
}"#, }
r#"fn foo(the_field: u32) -> Result<u32, ${0:_}> { "#,
r#"
fn foo(the_field: u32) -> Result<u32, ${0:_}> {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
match i { match i {
5 => return Ok(99), 5 => return Ok(99),
_ => return Ok(0), _ => return Ok(0),
} }
} }
Ok(the_field) Ok(the_field)
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo(the_field: u32) -> u32<|> { r#"
fn foo(the_field: u32) -> u32<|> {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if i == 5 { if i == 5 {
return 99 return 99
} else { } else {
return 0 return 0
} }
} }
the_field the_field
}"#, }
r#"fn foo(the_field: u32) -> Result<u32, ${0:_}> { "#,
r#"
fn foo(the_field: u32) -> Result<u32, ${0:_}> {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if i == 5 { if i == 5 {
return Ok(99) return Ok(99)
} else { } else {
return Ok(0) return Ok(0)
} }
} }
Ok(the_field) Ok(the_field)
}"#, }
"#,
); );
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo(the_field: u32) -> <|>u32 { r#"
fn foo(the_field: u32) -> <|>u32 {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if i == 5 { if i == 5 {
return 99; return 99;
} else { } else {
return 0; return 0;
} }
} }
the_field the_field
}"#, }
r#"fn foo(the_field: u32) -> Result<u32, ${0:_}> { "#,
r#"
fn foo(the_field: u32) -> Result<u32, ${0:_}> {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if i == 5 { if i == 5 {
return Ok(99); return Ok(99);
} else { } else {
return Ok(0); return Ok(0);
} }
} }
Ok(the_field) Ok(the_field)
}"#, }
"#,
); );
} }
} }