Commit 68b0fce62f

Henry Nelson <hcnelson99@gmail.com>
2018-12-10 06:50:12
Document explicitly ignoring expression values
1 parent 1b0f4d5
Changed files (1)
doc/langref.html.in
@@ -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();
+}
+
+test "explicitly ignoring expression value" {
+    _ = foo();
 }
 
-fn foo() void {}
+fn returnsVoid() void {}
+
+fn foo() i32 {
+    return 1234;
+}
       {#code_end#}
       {#header_close#}