Document explicitly ignoring expression values
parent
1b0f4d5976
commit
68b0fce62f
|
@ -4264,13 +4264,21 @@ fn foo() i32 {
|
|||
return 1234;
|
||||
}
|
||||
{#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#}
|
||||
test "ignoring expression value" {
|
||||
foo();
|
||||
test "void is ignored" {
|
||||
returnsVoid();
|
||||
}
|
||||
|
||||
fn foo() void {}
|
||||
test "explicitly ignoring expression value" {
|
||||
_ = foo();
|
||||
}
|
||||
|
||||
fn returnsVoid() void {}
|
||||
|
||||
fn foo() i32 {
|
||||
return 1234;
|
||||
}
|
||||
{#code_end#}
|
||||
{#header_close#}
|
||||
|
||||
|
|
Loading…
Reference in New Issue