From 3fc0c899c97977cc7843bf809c36dcdafb369144 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 2 Sep 2021 19:26:07 -0700 Subject: [PATCH] endsWith("") should return true Former-commit-id: fdbb66abc4e539ef960a72588495cd9964eff68b --- src/string_immutable.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 8706f40533..f488509083 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -203,7 +203,7 @@ pub fn startsWith(self: string, str: string) bool { } pub inline fn endsWith(self: string, str: string) bool { - return @call(.{ .modifier = .always_inline }, std.mem.endsWith, .{ u8, self, str }); + return str.len == 0 or @call(.{ .modifier = .always_inline }, std.mem.endsWith, .{ u8, self, str }); } pub fn endsWithAny(self: string, str: string) bool {