Skip to content

Commit 43df615

Browse files
committed
Introduce MustConstraints()
1 parent c2de231 commit 43df615

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

constraint.go

+10
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ func NewConstraint(v string) (Constraints, error) {
6666
return Constraints(result), nil
6767
}
6868

69+
// MustConstraints is a helper that wraps a call to a function
70+
// returning (Constraints, error) and panics if error is non-nil.
71+
func MustConstraints(c Constraints, err error) Constraints {
72+
if err != nil {
73+
panic(err)
74+
}
75+
76+
return c
77+
}
78+
6979
// Check tests if a version satisfies all the constraints.
7080
func (cs Constraints) Check(v *Version) bool {
7181
for _, c := range cs {

0 commit comments

Comments
 (0)