From 68b0fce62f684a4b491ebb36dea06bd4d9ff5219 Mon Sep 17 00:00:00 2001 From: Henry Nelson Date: Mon, 10 Dec 2018 00:50:12 -0500 Subject: [PATCH] Document explicitly ignoring expression values --- doc/langref.html.in | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 6e2d2bd9a..57da8a5f0 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -4264,13 +4264,21 @@ fn foo() i32 { return 1234; } {#code_end#} -

However, if the expression has type {#syntax#}void{#endsyntax#}:

+

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#}.

{#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#}