| ... | @@ -4264,13 +4264,21 @@ fn foo() i32 { | ... | @@ -4264,13 +4264,21 @@ fn foo() i32 { |
| 4264 | return 1234; | 4264 | return 1234; |
| 4265 | } | 4265 | } |
| 4266 | {#code_end#} | 4266 | {#code_end#} |
| 4267 | <p>However, if the expression has type {#syntax#}void{#endsyntax#}:</p> | 4267 | <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> |
| 4268 | {#code_begin|test#} | 4268 | {#code_begin|test#} |
| 4269 | test "ignoring expression value" { | 4269 | test "void is ignored" { |
| 4270 | foo(); | 4270 | returnsVoid(); |
| | 4271 | } |
| | 4272 | |
| | 4273 | test "explicitly ignoring expression value" { |
| | 4274 | _ = foo(); |
| 4271 | } | 4275 | } |
| 4272 | | 4276 | |
| 4273 | fn foo() void {} | 4277 | fn returnsVoid() void {} |
| | 4278 | |
| | 4279 | fn foo() i32 { |
| | 4280 | return 1234; |
| | 4281 | } |
| 4274 | {#code_end#} | 4282 | {#code_end#} |
| 4275 | {#header_close#} | 4283 | {#header_close#} |
| 4276 | | 4284 | |