Commit 8f7fc63847
Changed files (1)
src
src/Package.zig
@@ -66,11 +66,11 @@ pub const Hash = struct {
pub fn toSlice(ph: *const Hash) []const u8 {
var end: usize = ph.bytes.len;
- while (true) {
- if (end == 0) return &.{};
+ while (end > 0) {
end -= 1;
if (ph.bytes[end] != 0) return ph.bytes[0 .. end + 1];
}
+ return ph.bytes[0..0];
}
pub fn eql(a: *const Hash, b: *const Hash) bool {
@@ -196,7 +196,7 @@ test Hash {
try std.testing.expectEqualStrings("nasm-2.16.1-3-vrr-ygAAoADH9XG3tOdvPNuHen_d-XeHndOG-nNXmved", result.toSlice());
}
-test "EmptyHash" {
+test "empty hash" {
const hash = Hash.fromSlice("");
try std.testing.expectEqualStrings("", hash.toSlice());
}