Skip to content

Commit

Permalink
Introduce MustConstraints()
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Nov 18, 2021
1 parent c2de231 commit 43df615
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ func NewConstraint(v string) (Constraints, error) {
return Constraints(result), nil
}

// MustConstraints is a helper that wraps a call to a function
// returning (Constraints, error) and panics if error is non-nil.
func MustConstraints(c Constraints, err error) Constraints {
if err != nil {
panic(err)
}

return c
}

// Check tests if a version satisfies all the constraints.
func (cs Constraints) Check(v *Version) bool {
for _, c := range cs {
Expand Down

0 comments on commit 43df615

Please # to comment.