@@ -146,6 +146,42 @@ public enum VersionSetSpecifier: Hashable, CustomStringConvertible {
146146 }
147147}
148148
149+ /// A requirement that a package must satisfy.
150+ public enum PackageRequirement : Hashable {
151+
152+ /// The requirement is specified by the version set.
153+ case versionSet( VersionSetSpecifier )
154+
155+ /// The requirement is specified by the revision.
156+ ///
157+ /// The revision string (identifier) should be valid and present in the
158+ /// container. Only one revision requirement per container is possible
159+ /// i.e. two revision requirements for same container will lead to
160+ /// unsatisfiable resolution. The revision requirement can either come
161+ /// from initial set of constraints or from dependencies of a revision
162+ /// requirement.
163+ case revision( String )
164+
165+ /// Un-versioned requirement i.e. a version should not resolved.
166+ case unversioned
167+
168+ /// Returns if this requirement pins to an exact version, e.g. a specific
169+ /// version or a revision.
170+ public var isExact : Bool {
171+ switch self {
172+ case . versionSet( let vs) :
173+ if case . exact = vs {
174+ return true
175+ }
176+ return false
177+ case . revision:
178+ return true
179+ case . unversioned:
180+ return false
181+ }
182+ }
183+ }
184+
149185/// An identifier which unambiguously references a package container.
150186///
151187/// This identifier is used to abstractly refer to another container when
@@ -248,51 +284,15 @@ public protocol PackageContainerProvider {
248284public struct PackageContainerConstraint < T: PackageContainerIdentifier > : CustomStringConvertible , Equatable {
249285 public typealias Identifier = T
250286
251- /// The requirement of this constraint.
252- public enum Requirement : Hashable {
253-
254- /// The requirement is specified by the version set.
255- case versionSet( VersionSetSpecifier )
256-
257- /// The requirement is specified by the revision.
258- ///
259- /// The revision string (identifier) should be valid and present in the
260- /// container. Only one revision requirement per container is possible
261- /// i.e. two revision requirements for same container will lead to
262- /// unsatisfiable resolution. The revision requirement can either come
263- /// from initial set of constraints or from dependencies of a revision
264- /// requirement.
265- case revision( String )
266-
267- /// Un-versioned requirement i.e. a version should not resolved.
268- case unversioned
269-
270- /// Returns if this requirement pins to an exact version, e.g. a specific
271- /// version or a revision.
272- public var isExact : Bool {
273- switch self {
274- case . versionSet( let vs) :
275- if case . exact = vs {
276- return true
277- }
278- return false
279- case . revision( _) :
280- return true
281- case . unversioned:
282- return false
283- }
284- }
285- }
286-
287287 /// The identifier for the container the constraint is on.
288288 public let identifier : Identifier
289289
290290 /// The constraint requirement.
291- public let requirement : Requirement
291+ public let requirement : PackageRequirement
292292
293293 /// Create a constraint requiring the given `container` satisfying the
294294 /// `requirement`.
295- public init ( container identifier: Identifier , requirement: Requirement ) {
295+ public init ( container identifier: Identifier , requirement: PackageRequirement ) {
296296 self . identifier = identifier
297297 self . requirement = requirement
298298 }
@@ -367,7 +367,7 @@ public enum BoundVersion: Equatable, CustomStringConvertible {
367367public struct PackageContainerConstraintSet < C: PackageContainer > : Collection , Hashable {
368368 public typealias Container = C
369369 public typealias Identifier = Container . Identifier
370- public typealias Requirement = PackageContainerConstraint < Identifier > . Requirement
370+ public typealias Requirement = PackageRequirement
371371
372372 public typealias Index = Dictionary < Identifier , Requirement > . Index
373373 public typealias Element = Dictionary < Identifier , Requirement > . Element
0 commit comments