From 0dca6338056f1a3d3e4323320270df3ec3520fba Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Sun, 5 Jan 2025 09:20:32 +0100 Subject: [PATCH] Add array removal helper --- CHDataManagement.xcodeproj/project.pbxproj | 4 ++++ CHDataManagement/Extensions/Array+Remove.swift | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 CHDataManagement/Extensions/Array+Remove.swift diff --git a/CHDataManagement.xcodeproj/project.pbxproj b/CHDataManagement.xcodeproj/project.pbxproj index 79a0410..79eac55 100644 --- a/CHDataManagement.xcodeproj/project.pbxproj +++ b/CHDataManagement.xcodeproj/project.pbxproj @@ -211,6 +211,7 @@ E2FE0F192D2723E3002963B7 /* ImageSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F182D2723E3002963B7 /* ImageSet.swift */; }; E2FE0F1B2D274FDF002963B7 /* LinkPreviewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F1A2D274FDA002963B7 /* LinkPreviewItem.swift */; }; E2FE0F1E2D281AE1002963B7 /* TagOverviewGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F1D2D281ACE002963B7 /* TagOverviewGenerator.swift */; }; + E2FE0F202D29A70E002963B7 /* Array+Remove.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F1F2D29A709002963B7 /* Array+Remove.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -413,6 +414,7 @@ E2FE0F182D2723E3002963B7 /* ImageSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageSet.swift; sourceTree = ""; }; E2FE0F1A2D274FDA002963B7 /* LinkPreviewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkPreviewItem.swift; sourceTree = ""; }; E2FE0F1D2D281ACE002963B7 /* TagOverviewGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagOverviewGenerator.swift; sourceTree = ""; }; + E2FE0F1F2D29A709002963B7 /* Array+Remove.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+Remove.swift"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -778,6 +780,7 @@ E2B85F552C4BD0AD0047CD0C /* Extensions */ = { isa = PBXGroup; children = ( + E2FE0F1F2D29A709002963B7 /* Array+Remove.swift */, E2FE0EE72D16D4A3002963B7 /* ConvertThrowing.swift */, E25DA5182CFF035200AEF16D /* Array+Split.swift */, E2B85F562C4BD0BB0047CD0C /* Binding+Extension.swift */, @@ -955,6 +958,7 @@ E2FE0EFE2D266DA5002963B7 /* NavigationSettingsFile.swift in Sources */, E2FE0EE62D15A0B5002963B7 /* GenerationResults.swift in Sources */, E2FE0F152D26918F002963B7 /* PageHtmlProcessor.swift in Sources */, + E2FE0F202D29A70E002963B7 /* Array+Remove.swift in Sources */, E25DA5772D018B9900AEF16D /* File+Mock.swift in Sources */, E25DA5892D01CBD300AEF16D /* Content+Generation.swift in Sources */, E229904C2D10BE5D009F8D77 /* InitialSetupView.swift in Sources */, diff --git a/CHDataManagement/Extensions/Array+Remove.swift b/CHDataManagement/Extensions/Array+Remove.swift new file mode 100644 index 0000000..3297cac --- /dev/null +++ b/CHDataManagement/Extensions/Array+Remove.swift @@ -0,0 +1,12 @@ + +extension Array where Element: Equatable { + + @discardableResult + mutating func remove(_ element: Element) -> Bool { + guard let index = firstIndex(of: element) else { + return false + } + remove(at: index) + return true + } +}