AK: Add a Swift helper for StringView::ends_with

This commit is contained in:
Andrew Kaster 2024-11-14 16:03:02 -07:00 committed by Andrew Kaster
parent b895a135d5
commit e0adbf3ebb
Notes: github-actions[bot] 2024-11-15 17:56:57 +00:00

View file

@ -29,4 +29,11 @@ extension AK.StringView: ExpressibleByStringLiteral {
public init(stringLiteral value: StringLiteralType) {
self.init(value.utf8Start, value.utf8CodeUnitCount)
}
public func endsWith(_ suffix: AK.StringView) -> Bool {
if suffix.length() == 1 {
return self.ends_with(suffix[0])
}
return self.ends_with(suffix, AK.CaseSensitivity.sensitive)
}
}