RFC 9562 UUID implementation in Zig sites.wisp.place/jcollie.dev/uuid.zig/
zig uuid
1

Configure Feed

Select the types of activity you want to include in your feed.

don't copy hashes around

Jeffrey C. Ollie (Aug 13, 2025, 10:04 AM -0500) 5827a6c8 b7613e7c

+6 -6
+6 -6
src/root.zig
··· 131 131 }, 132 132 v2, 133 133 v3: struct { 134 - hash: [std.crypto.hash.Md5.digest_length]u8, 134 + hash: *const [std.crypto.hash.Md5.digest_length]u8, 135 135 136 136 pub fn parts(self: @This()) packed struct(u128) { 137 137 low: u62, ··· 140 140 _padding1: u4, 141 141 high: u48, 142 142 } { 143 - return @bitCast(std.mem.readInt(u128, &self.hash, .big)); 143 + return @bitCast(std.mem.readInt(u128, self.hash, .big)); 144 144 } 145 145 }, 146 146 v4, 147 147 v5: struct { 148 - hash: [std.crypto.hash.Sha1.digest_length]u8, 148 + hash: *const [std.crypto.hash.Sha1.digest_length]u8, 149 149 150 150 pub fn parts(self: @This()) packed struct(u160) { 151 151 _padding3: u32, ··· 155 155 _padding1: u4, 156 156 high: u48, 157 157 } { 158 - return @bitCast(std.mem.readInt(u160, &self.hash, .big)); 158 + return @bitCast(std.mem.readInt(u160, self.hash, .big)); 159 159 } 160 160 }, 161 161 v6: struct { ··· 558 558 559 559 const id: UUID = .new(.{ 560 560 .v3 = .{ 561 - .hash = .{ 0x5d, 0xf4, 0x18, 0x81, 0x3a, 0xed, 0x05, 0x15, 0x48, 0xa7, 0x2f, 0x4a, 0x81, 0x4c, 0xf0, 0x9e }, 561 + .hash = &[_]u8{ 0x5d, 0xf4, 0x18, 0x81, 0x3a, 0xed, 0x05, 0x15, 0x48, 0xa7, 0x2f, 0x4a, 0x81, 0x4c, 0xf0, 0x9e }, 562 562 }, 563 563 }); 564 564 ··· 623 623 const id: UUID = .new( 624 624 .{ 625 625 .v5 = .{ 626 - .hash = .{ 0x2e, 0xd6, 0x65, 0x7d, 0xe9, 0x27, 0x46, 0x8b, 0x55, 0xe1, 0x26, 0x65, 0xa8, 0xae, 0xa6, 0xa2, 0x2d, 0xee, 0x3e, 0x35 }, 626 + .hash = &[_]u8{ 0x2e, 0xd6, 0x65, 0x7d, 0xe9, 0x27, 0x46, 0x8b, 0x55, 0xe1, 0x26, 0x65, 0xa8, 0xae, 0xa6, 0xa2, 0x2d, 0xee, 0x3e, 0x35 }, 627 627 }, 628 628 }, 629 629 );