authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-07-14 17:12:03 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-07-14 17:12:03 -07:00
logd2834174ee6a0011ee42fe43be2886c539a146ce
treee2927da0c911b4224fb33cf0b39052b8c396cee1
parent27dd9c8d9e35e88225ac91052b94cba43d185aba

update to stdlib breakage


2 files changed, 4 insertions(+), 3 deletions(-)

ulid.zig+3-3
...@@ -19,14 +19,14 @@ pub const Factory = struct {...@@ -19,14 +19,14 @@ pub const Factory = struct {
19 pub fn newULID(self: Factory) ULID {19 pub fn newULID(self: Factory) ULID {
20 const now = std.time.milliTimestamp();20 const now = std.time.milliTimestamp();
21 return ULID{21 return ULID{
22 .timestamp = std.math.cast(u48, now - self.epoch) catch @panic("time.milliTimestamp() is higher than 281474976710655"),22 .timestamp = std.math.cast(u48, now - self.epoch) orelse @panic("time.milliTimestamp() is higher than 281474976710655"),
23 .randomnes = self.rand.int(u80),23 .randomnes = self.rand.int(u80),
24 };24 };
25 }25 }
26};26};
2727
28/// 01AN4Z07BY 79KA1307SR9X4MV328/// 01AN4Z07BY 79KA1307SR9X4MV3
29/// 29///
30/// |----------| |----------------|30/// |----------| |----------------|
31/// Timestamp Randomness31/// Timestamp Randomness
32/// 48bits 80bits32/// 48bits 80bits
...@@ -41,7 +41,7 @@ pub const ULID = struct {...@@ -41,7 +41,7 @@ pub const ULID = struct {
41 pub fn parse(alloc: std.mem.Allocator, value: BaseType) !ULID {41 pub fn parse(alloc: std.mem.Allocator, value: BaseType) !ULID {
42 if (value.len != 26) return error.Ulid;42 if (value.len != 26) return error.Ulid;
43 return ULID{43 return ULID{
44 .timestamp = try std.math.cast(u48, try extras.sliceToInt(u50, u5, try base32.decode(alloc, value[0..10]))),44 .timestamp = std.math.cast(u48, try extras.sliceToInt(u50, u5, try base32.decode(alloc, value[0..10]))) orelse return error.Ulid,
45 .randomnes = try extras.sliceToInt(u80, u5, try base32.decode(alloc, value[10..26])),45 .randomnes = try extras.sliceToInt(u80, u5, try base32.decode(alloc, value[10..26])),
46 };46 };
47 }47 }
zig.mod+1
...@@ -3,6 +3,7 @@ name: ulid...@@ -3,6 +3,7 @@ name: ulid
3main: ulid.zig3main: ulid.zig
4license: MIT4license: MIT
5description: ULID implementation for Zig5description: ULID implementation for Zig
6min_zig_version: 0.10.0-dev.2431+0e6285c8f
6dependencies:7dependencies:
7 - src: git https://github.com/nektro/zig-range8 - src: git https://github.com/nektro/zig-range
8 - src: git https://github.com/nektro/zig-extras9 - src: git https://github.com/nektro/zig-extras