| ... | @@ -426,29 +426,27 @@ pub const Version = struct { | ... | @@ -426,29 +426,27 @@ pub const Version = struct { |
| 426 | pub fn parse(text: []const u8) !Version { | 426 | pub fn parse(text: []const u8) !Version { |
| 427 | var it = std.mem.separate(text, "."); | 427 | var it = std.mem.separate(text, "."); |
| 428 | return Version{ | 428 | return Version{ |
| 429 | .major = try std.fmt.parseInt(u32, it.next() orelse return error.InvalidVersion, 10), | 429 | .major = try std.fmtstream.parseInt(u32, it.next() orelse return error.InvalidVersion, 10), |
| 430 | .minor = try std.fmt.parseInt(u32, it.next() orelse "0", 10), | 430 | .minor = try std.fmtstream.parseInt(u32, it.next() orelse "0", 10), |
| 431 | .patch = try std.fmt.parseInt(u32, it.next() orelse "0", 10), | 431 | .patch = try std.fmtstream.parseInt(u32, it.next() orelse "0", 10), |
| 432 | }; | 432 | }; |
| 433 | } | 433 | } |
| 434 | | 434 | |
| 435 | pub fn format( | 435 | pub fn format( |
| 436 | self: Version, | 436 | self: Version, |
| 437 | comptime fmt: []const u8, | 437 | comptime fmt: []const u8, |
| 438 | options: std.fmt.FormatOptions, | 438 | options: std.fmtstream.FormatOptions, |
| 439 | context: var, | 439 | out_stream: var, |
| 440 | comptime Error: type, | 440 | ) !void { |
| 441 | comptime output: fn (@TypeOf(context), []const u8) Error!void, | | |
| 442 | ) Error!void { | | |
| 443 | if (fmt.len == 0) { | 441 | if (fmt.len == 0) { |
| 444 | if (self.patch == 0) { | 442 | if (self.patch == 0) { |
| 445 | if (self.minor == 0) { | 443 | if (self.minor == 0) { |
| 446 | return std.fmt.format(context, Error, output, "{}", .{self.major}); | 444 | return std.fmtstream.format(out_stream, "{}", .{self.major}); |
| 447 | } else { | 445 | } else { |
| 448 | return std.fmt.format(context, Error, output, "{}.{}", .{ self.major, self.minor }); | 446 | return std.fmtstream.format(out_stream, "{}.{}", .{ self.major, self.minor }); |
| 449 | } | 447 | } |
| 450 | } else { | 448 | } else { |
| 451 | return std.fmt.format(context, Error, output, "{}.{}.{}", .{ self.major, self.minor, self.patch }); | 449 | return std.fmtstream.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch }); |
| 452 | } | 450 | } |
| 453 | } else { | 451 | } else { |
| 454 | @compileError("Unknown format string: '" ++ fmt ++ "'"); | 452 | @compileError("Unknown format string: '" ++ fmt ++ "'"); |