diff options
| author | Benjamin Feng <benjamin.feng@glassdoor.com> | 2020-03-06 08:59:21 -0600 |
|---|---|---|
| committer | Benjamin Feng <benjamin.feng@glassdoor.com> | 2020-03-12 10:41:04 -0500 |
| commit | 0fbccec000efcfe23188027e474530641daf67cd (patch) | |
| tree | a4893c26086659c9c5bf7446de630c20f458f3c3 /lib/std/builtin.zig | |
| parent | c11d1055b868add74cc58f3bf745e93110ae6071 (diff) | |
| download | zig-0fbccec000efcfe23188027e474530641daf67cd.tar.gz zig-0fbccec000efcfe23188027e474530641daf67cd.zip | |
Convert builtin to fmtstream
Diffstat (limited to 'lib/std/builtin.zig')
| -rw-r--r-- | lib/std/builtin.zig | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index fa5b49db37..5cac8c9622 100644 --- 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 ++ "'"); |
