| ... | @@ -45,10 +45,10 @@ pub const ULID = struct { | ... | @@ -45,10 +45,10 @@ pub const ULID = struct { |
| 45 | } | 45 | } |
| 46 | | 46 | |
| 47 | pub fn bindField(self: ULID, alloc: *std.mem.Allocator) !BaseType { | 47 | pub fn bindField(self: ULID, alloc: *std.mem.Allocator) !BaseType { |
| 48 | var res = try alloc.alloc(u8, 26); | 48 | var res = try std.ArrayList(u8).initCapacity(alloc, 26); |
| 49 | base32.formatInt(u48, self.timestamp, res[0..10]); | 49 | defer res.deinit(); |
| 50 | base32.formatInt(u80, self.randomnes, res[10..26]); | 50 | try res.writer().print("{}", .{self}); |
| 51 | return res; | 51 | return res.toOwnedSlice(); |
| 52 | } | 52 | } |
| 53 | | 53 | |
| 54 | pub const fromString = readField; | 54 | pub const fromString = readField; |