aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorJimmi Holst Christensen <jimmi@ziglang.org>2018-12-19 16:07:35 +0100
committerAndrew Kelley <andrew@ziglang.org>2018-12-19 10:07:35 -0500
commita7670e80a49021fb96d1f9a1bbcbcfc6c1e835ab (patch)
tree1417f949edd37999f7f18286dd5e3075172645a3 /std
parent45e72c0b3944b2fa6d06c7018e9648b4ae60006a (diff)
downloadzig-a7670e80a49021fb96d1f9a1bbcbcfc6c1e835ab.tar.gz
zig-a7670e80a49021fb96d1f9a1bbcbcfc6c1e835ab.zip
Added formatting of function pointers (#1843)
Diffstat (limited to 'std')
-rw-r--r--std/fmt/index.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/std/fmt/index.zig b/std/fmt/index.zig
index adf2882f35..b010072273 100644
--- a/std/fmt/index.zig
+++ b/std/fmt/index.zig
@@ -243,6 +243,9 @@ pub fn formatType(
}
return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(&value));
},
+ builtin.TypeId.Fn => {
+ return format(context, Errors, output, "{}@{x}", @typeName(T), @ptrToInt(value));
+ },
else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),
}
}
@@ -1013,6 +1016,10 @@ test "fmt.format" {
const value = @intToPtr(fn () void, 0xdeadbeef);
try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", value);
}
+ {
+ const value = @intToPtr(fn () void, 0xdeadbeef);
+ try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", value);
+ }
try testFmt("buf: Test \n", "buf: {s5}\n", "Test");
try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", "Test");
try testFmt("cstr: Test C\n", "cstr: {s}\n", c"Test C");