From bc5deb5b61e3d27811bf525301830d332a7cd0dd Mon Sep 17 00:00:00 2001 From: Steffan Andrews Date: Tue, 24 Dec 2024 15:56:10 -0800 Subject: [PATCH] `ComparisonResult`: Added `inverted` property --- .../Collections and Foundation.swift | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Sources/OTCore/Extensions/Foundation/Collections and Foundation.swift diff --git a/Sources/OTCore/Extensions/Foundation/Collections and Foundation.swift b/Sources/OTCore/Extensions/Foundation/Collections and Foundation.swift new file mode 100644 index 0000000..84c743d --- /dev/null +++ b/Sources/OTCore/Extensions/Foundation/Collections and Foundation.swift @@ -0,0 +1,26 @@ +// +// Collections and Foundation.swift +// OTCore • https://github.com/orchetect/OTCore +// © 2024 Steffan Andrews • Licensed under MIT License +// + +#if canImport(Foundation) + +import Foundation + +// MARK: - Comparison + +extension ComparisonResult { + /// **OTCore:** + /// Returns the inverted comparison result. + @inlinable @_disfavoredOverload + public var inverted: Self { + switch self { + case .orderedAscending: .orderedDescending + case .orderedSame: .orderedSame + case .orderedDescending: .orderedAscending + } + } +} + +#endif