authorgravatar for kiedtl@tilde.teamKiëd Llaentenn <kiedtl@tilde.team> 2025-03-05 09:08:47-05:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-06 07:26:19+01:00
log5f7dfc357740e765fad3d8deb246b6dd9aef3fc0
tree6558502f4bd146f199aed0987ffbc915d078f09e
parent79460d4a3eef8eb927b02a7eda8bc9999a766672

langref: update splat section


2 files changed, 9 insertions(+), 2 deletions(-)

doc/langref.html.in+3-2
......@@ -5498,8 +5498,9 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
54985498 {#header_open|@splat#}
54995499 <pre>{#syntax#}@splat(scalar: anytype) anytype{#endsyntax#}</pre>
55005500 <p>
5501 Produces a vector where each element is the value {#syntax#}scalar{#endsyntax#}.
5502 The return type and thus the length of the vector is inferred.
5501 Produces an array or vector where each element is the value
5502 {#syntax#}scalar{#endsyntax#}. The return type and thus the length of the
5503 vector is inferred.
55035504 </p>
55045505 {#code|test_splat_builtin.zig#}
55055506
doc/langref/test_splat_builtin.zig+6
......@@ -7,4 +7,10 @@ test "vector @splat" {
77 try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
88}
99
10test "array @splat" {
11 const scalar: u32 = 5;
12 const result: [4]u32 = @splat(scalar);
13 try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
14}
15
1016// test