authorgravatar for data-man@users.noreply.github.comDmitry Atamanov <data-man@users.noreply.github.com> 2020-05-29 08:10:16+05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-05-28 23:10:16-04:00
log0328537ca641e0b24218f303c7a1bf0440cd7115
tree5e4f09ef0bb5b8e897a77447ab7a81c75b17e1c3
parent8630ae7523362e00efe9cc914cf05dcef09c3500
signature Signed by PGP key 4AEE18F83AFDEB23

Support stringify for vectors (#5441)

* use array's pointer

1 files changed, 9 insertions(+), 0 deletions(-)

lib/std/json.zig+9
......@@ -2575,6 +2575,10 @@ pub fn stringify(
25752575 else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),
25762576 },
25772577 .Array => return stringify(&value, options, out_stream),
2578 .Vector => |info| {
2579 const array: [info.len]info.child = value;
2580 return stringify(&array, options, out_stream);
2581 },
25782582 else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),
25792583 }
25802584 unreachable;
......@@ -2762,3 +2766,8 @@ test "stringify struct with custom stringifier" {
27622766 }
27632767 }{ .foo = 42 }, StringifyOptions{});
27642768}
2769
2770test "stringify vector" {
2771 try teststringify("[1,1]", @splat(2, @as(u32, 1)), StringifyOptions{});
2772}
2773