| ... | ... | @@ -14,15 +14,15 @@ const expectFmt = std.testing.expectFmt; |
| 14 | 14 | pub const default_max_depth = 3; |
| 15 | 15 | |
| 16 | 16 | pub const Alignment = enum { |
| 17 | | Left, |
| 18 | | Center, |
| 19 | | Right, |
| 17 | left, |
| 18 | center, |
| 19 | right, |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | 22 | pub const FormatOptions = struct { |
| 23 | 23 | precision: ?usize = null, |
| 24 | 24 | width: ?usize = null, |
| 25 | | alignment: Alignment = .Right, |
| 25 | alignment: Alignment = .right, |
| 26 | 26 | fill: u8 = ' ', |
| 27 | 27 | }; |
| 28 | 28 | |
| ... | ... | @@ -252,11 +252,11 @@ pub const Placeholder = struct { |
| 252 | 252 | else => {}, |
| 253 | 253 | } |
| 254 | 254 | break :init switch (ch) { |
| 255 | | '<' => .Left, |
| 256 | | '^' => .Center, |
| 257 | | else => .Right, |
| 255 | '<' => .left, |
| 256 | '^' => .center, |
| 257 | else => .right, |
| 258 | 258 | }; |
| 259 | | } else .Right; |
| 259 | } else .right; |
| 260 | 260 | |
| 261 | 261 | // Parse the width parameter |
| 262 | 262 | const width = comptime parser.specifier() catch |err| |
| ... | ... | @@ -1034,18 +1034,18 @@ pub fn formatBuf( |
| 1034 | 1034 | return writer.writeAll(buf); |
| 1035 | 1035 | |
| 1036 | 1036 | switch (options.alignment) { |
| 1037 | | .Left => { |
| 1037 | .left => { |
| 1038 | 1038 | try writer.writeAll(buf); |
| 1039 | 1039 | try writer.writeByteNTimes(options.fill, padding); |
| 1040 | 1040 | }, |
| 1041 | | .Center => { |
| 1041 | .center => { |
| 1042 | 1042 | const left_padding = padding / 2; |
| 1043 | 1043 | const right_padding = (padding + 1) / 2; |
| 1044 | 1044 | try writer.writeByteNTimes(options.fill, left_padding); |
| 1045 | 1045 | try writer.writeAll(buf); |
| 1046 | 1046 | try writer.writeByteNTimes(options.fill, right_padding); |
| 1047 | 1047 | }, |
| 1048 | | .Right => { |
| 1048 | .right => { |
| 1049 | 1049 | try writer.writeByteNTimes(options.fill, padding); |
| 1050 | 1050 | try writer.writeAll(buf); |
| 1051 | 1051 | }, |