| ... | ... | @@ -66,11 +66,11 @@ pub const Hash = struct { |
| 66 | 66 | |
| 67 | 67 | pub fn toSlice(ph: *const Hash) []const u8 { |
| 68 | 68 | var end: usize = ph.bytes.len; |
| 69 | | while (true) { |
| 70 | | if (end == 0) return &.{}; |
| 69 | while (end > 0) { |
| 71 | 70 | end -= 1; |
| 72 | 71 | if (ph.bytes[end] != 0) return ph.bytes[0 .. end + 1]; |
| 73 | 72 | } |
| 73 | return ph.bytes[0..0]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | pub fn eql(a: *const Hash, b: *const Hash) bool { |
| ... | ... | @@ -196,7 +196,7 @@ test Hash { |
| 196 | 196 | try std.testing.expectEqualStrings("nasm-2.16.1-3-vrr-ygAAoADH9XG3tOdvPNuHen_d-XeHndOG-nNXmved", result.toSlice()); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | | test "EmptyHash" { |
| 199 | test "empty hash" { |
| 200 | 200 | const hash = Hash.fromSlice(""); |
| 201 | 201 | try std.testing.expectEqualStrings("", hash.toSlice()); |
| 202 | 202 | } |