File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ extension SemanticVersion.PreReleaseIdentifier: Comparable {
116
116
}
117
117
118
118
119
+ #if compiler(>=6)
119
120
extension Array : @retroactive Comparable where Element == SemanticVersion . PreReleaseIdentifier {
120
121
public static func < ( lhs: Self , rhs: Self ) -> Bool {
121
122
// Per section 11.4 of the semver spec, compare left to right until a
@@ -130,6 +131,23 @@ extension Array: @retroactive Comparable where Element == SemanticVersion.PreRel
130
131
return lhs. count < rhs. count
131
132
}
132
133
}
134
+ #else
135
+ extension Array : @retroactive Comparable where Element == SemanticVersion . PreReleaseIdentifier {
136
+ public static func < ( lhs: Self , rhs: Self ) -> Bool {
137
+ // Per section 11.4 of the semver spec, compare left to right until a
138
+ // difference is found.
139
+ // See: https://semver.org/#spec-item-11
140
+ for (lhIdentifier, rhIdentifier) in zip ( lhs, rhs) {
141
+ if lhIdentifier != rhIdentifier { return lhIdentifier < rhIdentifier }
142
+ }
143
+
144
+ // 11.4.4 - A larger set of identifiers will have a higher precendence
145
+ // than a smaller set, if all the preceding identifiers are equal.
146
+ return lhs. count < rhs. count
147
+ }
148
+ }
149
+ #endif
150
+
133
151
134
152
#if swift(>=5.5)
135
153
extension SemanticVersion : Sendable { }
You can’t perform that action at this time.
0 commit comments