From 837750e0801dde00828bc9dfcf46664a0824cd60 Mon Sep 17 00:00:00 2001 From: Rick van Voorden Date: Tue, 7 Oct 2025 16:06:21 -0700 Subject: [PATCH] add is identical methods updates --- proposals/0494-add-is-identical-methods.md | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/proposals/0494-add-is-identical-methods.md b/proposals/0494-add-is-identical-methods.md index 076d35f9a5..007c875549 100644 --- a/proposals/0494-add-is-identical-methods.md +++ b/proposals/0494-add-is-identical-methods.md @@ -21,6 +21,8 @@ * [`ContiguousArray`](#contiguousarray) * [`Dictionary`](#dictionary) * [`Set`](#set) + * [`UnsafeBufferPointer`](#unsafebufferpointer) + * [`UTF8Span`](#utf8span) * [Source Compatibility](#source-compatibility) * [Impact on ABI](#impact-on-abi) * [Future Directions](#future-directions) @@ -405,6 +407,11 @@ We propose adding `isIdentical` methods to the following concrete types from Sta * `ContiguousArray` * `Dictionary` * `Set` +* `UnsafeBufferPointer` +* `UnsafeMutableBufferPointer` +* `UnsafeMutableRawBufferPointer` +* `UnsafeRawBufferPointer` +* `UTF8Span` For each type being presented we codify important semantics in our header documentation. @@ -690,6 +697,30 @@ extension Set { } ``` +### `UnsafeBufferPointer` + +```swift +extension UnsafeBufferPointer where Element: ~Copyable { + /// Returns a Boolean value indicating whether two `UnsafeBufferPointer` + /// instances refer to the same region in memory. + public func isIdentical(to other: Self) -> Bool { ... } +} +``` + +The following types will adopt the same semantic guarantees as `UnsafeBufferPointer`: +* `UnsafeMutableBufferPointer` +* `UnsafeMutableRawBufferPointer` +* `UnsafeRawBufferPointer` + +### `UTF8Span` + +```swift +extension UTF8Span where Element: ~Copyable { + /// Returns a Boolean value indicating whether two `UTF8Span` instances + /// refer to the same region in memory. + public func isIdentical(to other: Self) -> Bool { ... } +``` + ## Source Compatibility This proposal is additive and source-compatible with existing code.