From 80c67c2eff941581c8bb48c304c2b9e45d44f3cc Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Wed, 24 Jul 2024 17:03:23 -0700 Subject: [PATCH] add identity operator --- Sources/Future/RawSpan.swift | 9 +++++++++ Sources/Future/Span.swift | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/Sources/Future/RawSpan.swift b/Sources/Future/RawSpan.swift index 4b1058b5..e9bdeeaf 100644 --- a/Sources/Future/RawSpan.swift +++ b/Sources/Future/RawSpan.swift @@ -111,6 +111,15 @@ extension RawSpan { } } +extension RawSpan { + /// Returns a Boolean value indicating whether two `RawSpan` instances + /// refer to the same region in memory. + @inlinable @inline(__always) + public static func ===(_ a: Self, _ b: Self) -> Bool { + (a._pointer == b._pointer) && (a._count == b._count) + } +} + extension RawSpan { /// The number of bytes in the span. diff --git a/Sources/Future/Span.swift b/Sources/Future/Span.swift index 7f05fff9..a8f301a0 100644 --- a/Sources/Future/Span.swift +++ b/Sources/Future/Span.swift @@ -328,6 +328,15 @@ extension Span where Element: Equatable { } } +extension Span where Element: ~Copyable /*& ~Escapable*/ { + /// Returns a Boolean value indicating whether two `RawSpan` instances + /// refer to the same region in memory. + @inlinable @inline(__always) + public static func ===(_ a: Self, _ b: Self) -> Bool { + (a._pointer == b._pointer) && (a._count == b._count) + } +} + extension Span where Element: ~Copyable /*& ~Escapable*/ { /// The number of elements in the span.