authorgravatar for manlio.perillo@gmail.comManlio Perillo <manlio.perillo@gmail.com> 2022-12-09 11:53:26+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-09 17:42:25+02:00
log505a21bcc5e06c156f33551e8abea90db438f41d
treeddb6e8570a1165973024d15e0abbf0549563550c
parentd88eb75a69d27ef50635f9aa1caf2a7177d99ead

langref: link "result location" to the "Result Location Semantics" section


1 files changed, 6 insertions(+), 5 deletions(-)

doc/langref.html.in+6-5
...@@ -2415,8 +2415,8 @@ test "anonymous list literal syntax" {...@@ -2415,8 +2415,8 @@ test "anonymous list literal syntax" {
2415}2415}
2416 {#code_end#}2416 {#code_end#}
2417 <p>2417 <p>
2418 If there is no type in the result location then an anonymous list literal actually2418 If there is no type in the {#link|result location|Result Location Semantics#} then an
2419 turns into a {#link|struct#} with numbered field names:2419 anonymous list literal actually turns into a {#link|struct#} with numbered field names:
2420 </p>2420 </p>
2421 {#code_begin|test|infer_list_literal#}2421 {#code_begin|test|infer_list_literal#}
2422const std = @import("std");2422const std = @import("std");
...@@ -3497,7 +3497,8 @@ fn List(comptime T: type) type {...@@ -3497,7 +3497,8 @@ fn List(comptime T: type) type {
3497 {#header_open|Anonymous Struct Literals#}3497 {#header_open|Anonymous Struct Literals#}
3498 <p>3498 <p>
3499 Zig allows omitting the struct type of a literal. When the result is {#link|coerced|Type Coercion#},3499 Zig allows omitting the struct type of a literal. When the result is {#link|coerced|Type Coercion#},
3500 the struct literal will directly instantiate the result location, with no copy:3500 the struct literal will directly instantiate the {#link|result location|Result Location Semantics#},
3501 with no copy:
3501 </p>3502 </p>
3502 {#code_begin|test|struct_result#}3503 {#code_begin|test|struct_result#}
3503const std = @import("std");3504const std = @import("std");
...@@ -3515,8 +3516,8 @@ test "anonymous struct literal" {...@@ -3515,8 +3516,8 @@ test "anonymous struct literal" {
3515}3516}
3516 {#code_end#}3517 {#code_end#}
3517 <p>3518 <p>
3518 The struct type can be inferred. Here the result location does not include a type, and3519 The struct type can be inferred. Here the {#link|result location|Result Location Semantics#}
3519 so Zig infers the type:3520 does not include a type, and so Zig infers the type:
3520 </p>3521 </p>
3521 {#code_begin|test|struct_anon#}3522 {#code_begin|test|struct_anon#}
3522const std = @import("std");3523const std = @import("std");