Document explicitly ignoring expression values
parent
1b0f4d5976
commit
68b0fce62f
|
@ -4264,13 +4264,21 @@ fn foo() i32 {
|
||||||
return 1234;
|
return 1234;
|
||||||
}
|
}
|
||||||
{#code_end#}
|
{#code_end#}
|
||||||
<p>However, if the expression has type {#syntax#}void{#endsyntax#}:</p>
|
<p>However, if the expression has type {#syntax#}void{#endsyntax#}, there will be no error. Function return values can also be explicitly ignored by assigning them to {#syntax#}_{#endsyntax#}. </p>
|
||||||
{#code_begin|test#}
|
{#code_begin|test#}
|
||||||
test "ignoring expression value" {
|
test "void is ignored" {
|
||||||
foo();
|
returnsVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo() void {}
|
test "explicitly ignoring expression value" {
|
||||||
|
_ = foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn returnsVoid() void {}
|
||||||
|
|
||||||
|
fn foo() i32 {
|
||||||
|
return 1234;
|
||||||
|
}
|
||||||
{#code_end#}
|
{#code_end#}
|
||||||
{#header_close#}
|
{#header_close#}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue