[stdlib] Substring.UnicodeScalarView: Add _invariantCheck

This commit is contained in:
Karoy Lorentey
2022-04-04 18:01:42 -07:00
parent f7c674ed55
commit 2e9fd9eb6b
2 changed files with 20 additions and 0 deletions

View File

@@ -357,6 +357,7 @@ extension _StringGuts {
/// index, but it is guaranteed to never incorrectly return false. If all
/// loaded binaries were built in 5.7+, then this method is guaranteed to
/// always return the correct value.
@_alwaysEmitIntoClient
internal func hasMatchingEncoding(_ i: String.Index) -> Bool {
(isForeign && i._canBeUTF16) || (!isForeign && i._canBeUTF8)
}