zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 0fbccec000efcfe23188027e474530641daf67cd (tree)
parent c11d1055b868add74cc58f3bf745e93110ae6071
Author: Benjamin Feng <benjamin.feng@glassdoor.com>
Date:   Fri,  6 Mar 2020 08:59:21 -0600

Convert builtin to fmtstream

Diffstat:
Mlib/std/builtin.zig | 20+++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig @@ -426,29 +426,27 @@ pub const Version = struct { pub fn parse(text: []const u8) !Version { var it = std.mem.separate(text, "."); return Version{ - .major = try std.fmt.parseInt(u32, it.next() orelse return error.InvalidVersion, 10), - .minor = try std.fmt.parseInt(u32, it.next() orelse "0", 10), - .patch = try std.fmt.parseInt(u32, it.next() orelse "0", 10), + .major = try std.fmtstream.parseInt(u32, it.next() orelse return error.InvalidVersion, 10), + .minor = try std.fmtstream.parseInt(u32, it.next() orelse "0", 10), + .patch = try std.fmtstream.parseInt(u32, it.next() orelse "0", 10), }; } pub fn format( self: Version, comptime fmt: []const u8, - options: std.fmt.FormatOptions, - context: var, - comptime Error: type, - comptime output: fn (@TypeOf(context), []const u8) Error!void, - ) Error!void { + options: std.fmtstream.FormatOptions, + out_stream: var, + ) !void { if (fmt.len == 0) { if (self.patch == 0) { if (self.minor == 0) { - return std.fmt.format(context, Error, output, "{}", .{self.major}); + return std.fmtstream.format(out_stream, "{}", .{self.major}); } else { - return std.fmt.format(context, Error, output, "{}.{}", .{ self.major, self.minor }); + return std.fmtstream.format(out_stream, "{}.{}", .{ self.major, self.minor }); } } else { - return std.fmt.format(context, Error, output, "{}.{}.{}", .{ self.major, self.minor, self.patch }); + return std.fmtstream.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch }); } } else { @compileError("Unknown format string: '" ++ fmt ++ "'");