Add isTriviallyIdentical for unicode views

This commit is contained in:
WindowsMEMZ
2025-10-28 18:56:18 +08:00
committed by Rick van Voorden
parent c8202c6f9a
commit be5ec1aed4
4 changed files with 69 additions and 0 deletions

View File

@@ -684,3 +684,14 @@ extension String.UTF8View {
return unsafe try _guts.withFastUTF8(body)
}
}
extension String.UTF8View {
/// Returns a boolean value indicating whether this UTF8 view
/// is trivially identical to `other`.
///
/// - Complexity: O(1)
@_alwaysEmitIntoClient
public func isTriviallyIdentical(to other: Self) -> Bool {
self._guts.rawBits == other._guts.rawBits
}
}