From 6a9b3814260c6e35c852930e2abfb6b852195f30 Mon Sep 17 00:00:00 2001 From: Wade Tregaskis Date: Sat, 2 Mar 2024 21:34:48 -0800 Subject: [PATCH] Revert "Added `count` and `isEmpty` properties to ContiguousBytes." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8ae54df4f3c01da1285c313bf187578797636330. It turns out this causes problems for ContiguousBytes types that already have an `isEmpty` property, "error: ambiguous use of 'isEmpty'". Which makes sense but is disappointing - there doesn't seem to be any way to declare an extension that defers to other implementations if they already exist. 😔 --- .../ContiguousBytes.swift | 16 ------------- .../ContiguousBytesTests.swift | 24 ------------------- 2 files changed, 40 deletions(-) delete mode 100644 Sources/FoundationExtensions/ContiguousBytes.swift delete mode 100644 Tests/FoundationExtensionsTests/ContiguousBytesTests.swift diff --git a/Sources/FoundationExtensions/ContiguousBytes.swift b/Sources/FoundationExtensions/ContiguousBytes.swift deleted file mode 100644 index a22d40a..0000000 --- a/Sources/FoundationExtensions/ContiguousBytes.swift +++ /dev/null @@ -1,16 +0,0 @@ -// Created by Wade Tregaskis on 2024-03-02. - -import Foundation - - -public extension ContiguousBytes { - var count: Int { - self.withUnsafeBytes { - $0.count - } - } - - var isEmpty: Bool { - 0 == self.count - } -} diff --git a/Tests/FoundationExtensionsTests/ContiguousBytesTests.swift b/Tests/FoundationExtensionsTests/ContiguousBytesTests.swift deleted file mode 100644 index bffce8c..0000000 --- a/Tests/FoundationExtensionsTests/ContiguousBytesTests.swift +++ /dev/null @@ -1,24 +0,0 @@ -// Created by Wade Tregaskis on 2024-03-02. - -import XCTest -@testable import FoundationExtensions - - -final class ContiguousBytesTests: XCTestCase { - func doTestCountAndIsEmpty>(for tipe: C.Type) { - for i in [0, 1, 2, 8, 16, 255] { - let data = C(repeating: 0, count: i) - - XCTAssertEqual(data.count, i) - XCTAssertEqual(data.isEmpty, 0 == i) - } - } - - func testCountAndIsEmpty() throws { - doTestCountAndIsEmpty(for: Data.self) - doTestCountAndIsEmpty(for: [UInt8].self) - doTestCountAndIsEmpty(for: ContiguousArray.self) - doTestCountAndIsEmpty(for: ArraySlice.self) - doTestCountAndIsEmpty(for: Slice<[UInt8]>.self) - } -}