Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions proposals/0494-add-is-identical-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down