Former-commit-id: 2c20d88e8d
This commit is contained in:
Jarred Sumner
2021-05-12 01:46:58 -07:00
parent 175bbdd3c3
commit f8131f42bc
18 changed files with 1601 additions and 183 deletions

View File

@@ -45,6 +45,21 @@ pub fn startsWith(self: string, str: string) bool {
return true;
}
pub fn endsWith(self: string, str: string) bool {
if (str.len > self.len) {
return false;
}
var i: usize = str.len - 1;
while (i > 0) : (i -= 1) {
if (str[i] != self[i]) {
return false;
}
}
return true;
}
pub fn endsWithAny(self: string, str: string) bool {
const end = self[self.len - 1];
for (str) |char| {