Commit 5f7dfc3577

Kiëd Llaentenn <kiedtl@tilde.team>
2025-03-05 15:08:47
langref: update splat section
1 parent 79460d4
Changed files (2)
doc/langref/test_splat_builtin.zig
@@ -7,4 +7,10 @@ test "vector @splat" {
     try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
 }
 
+test "array @splat" {
+    const scalar: u32 = 5;
+    const result: [4]u32 = @splat(scalar);
+    try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
+}
+
 // test
doc/langref.html.in
@@ -5498,8 +5498,9 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
       {#header_open|@splat#}
       <pre>{#syntax#}@splat(scalar: anytype) anytype{#endsyntax#}</pre>
       <p>
-      Produces a vector where each element is the value {#syntax#}scalar{#endsyntax#}.
-      The return type and thus the length of the vector is inferred.
+      Produces an array or vector where each element is the value
+      {#syntax#}scalar{#endsyntax#}. The return type and thus the length of the
+      vector is inferred.
       </p>
       {#code|test_splat_builtin.zig#}