From 154f1d32366449dcccf6375a173adf4ed2a74429 Mon Sep 17 00:00:00 2001 From: Sebastian Vogt Date: Wed, 9 Feb 2022 14:05:28 +0100 Subject: [PATCH] Implement BBV custom contains function. (#2044) --- Sources/NIOCore/ByteBuffer-views.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/NIOCore/ByteBuffer-views.swift b/Sources/NIOCore/ByteBuffer-views.swift index 542be67654..950ddf015c 100644 --- a/Sources/NIOCore/ByteBuffer-views.swift +++ b/Sources/NIOCore/ByteBuffer-views.swift @@ -113,6 +113,13 @@ public struct ByteBufferView: RandomAccessCollection { return ptr.lastIndex(of: element).map { $0 + self._range.lowerBound } }) } + + @inlinable + public func _customContainsEquatableElement(_ element: Element) -> Bool? { + return .some(self.withUnsafeBytes { ptr -> Bool in + return ptr.contains(element) + }) + } @inlinable public func _copyContents(