From 6dd5abbe4d72caf88188ec0d1cb56bcad4cd95b4 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 21 Oct 2021 21:14:29 -0700 Subject: [PATCH] rework bindField to capture format --- ulid.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ulid.zig b/ulid.zig index de000254341408e7be3d4fd5b19213e129b8509b..18f1be0ff714e610c7a342051ff1a5ce0a5c27d8 100644 --- a/ulid.zig +++ b/ulid.zig @@ -45,10 +45,10 @@ pub const ULID = struct { } pub fn bindField(self: ULID, alloc: *std.mem.Allocator) !BaseType { - var res = try alloc.alloc(u8, 26); - base32.formatInt(u48, self.timestamp, res[0..10]); - base32.formatInt(u80, self.randomnes, res[10..26]); - return res; + var res = try std.ArrayList(u8).initCapacity(alloc, 26); + defer res.deinit(); + try res.writer().print("{}", .{self}); + return res.toOwnedSlice(); } pub const fromString = readField; -- 2.54.0