mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update github.com/hashicorp/hcl/v2 to v2.19.1
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
22
vendor/github.com/zclconf/go-cty/cty/set/set.go
generated
vendored
22
vendor/github.com/zclconf/go-cty/cty/set/set.go
generated
vendored
@ -19,20 +19,20 @@ import (
|
||||
// Set operations are not optimized to minimize memory pressure. Mutating
|
||||
// a set will generally create garbage and so should perhaps be avoided in
|
||||
// tight loops where memory pressure is a concern.
|
||||
type Set struct {
|
||||
vals map[int][]interface{}
|
||||
rules Rules
|
||||
type Set[T any] struct {
|
||||
vals map[int][]T
|
||||
rules Rules[T]
|
||||
}
|
||||
|
||||
// NewSet returns an empty set with the membership rules given.
|
||||
func NewSet(rules Rules) Set {
|
||||
return Set{
|
||||
vals: map[int][]interface{}{},
|
||||
func NewSet[T any](rules Rules[T]) Set[T] {
|
||||
return Set[T]{
|
||||
vals: map[int][]T{},
|
||||
rules: rules,
|
||||
}
|
||||
}
|
||||
|
||||
func NewSetFromSlice(rules Rules, vals []interface{}) Set {
|
||||
func NewSetFromSlice[T any](rules Rules[T], vals []T) Set[T] {
|
||||
s := NewSet(rules)
|
||||
for _, v := range vals {
|
||||
s.Add(v)
|
||||
@ -40,11 +40,11 @@ func NewSetFromSlice(rules Rules, vals []interface{}) Set {
|
||||
return s
|
||||
}
|
||||
|
||||
func sameRules(s1 Set, s2 Set) bool {
|
||||
func sameRules[T any](s1 Set[T], s2 Set[T]) bool {
|
||||
return s1.rules.SameRules(s2.rules)
|
||||
}
|
||||
|
||||
func mustHaveSameRules(s1 Set, s2 Set) {
|
||||
func mustHaveSameRules[T any](s1 Set[T], s2 Set[T]) {
|
||||
if !sameRules(s1, s2) {
|
||||
panic(fmt.Errorf("incompatible set rules: %#v, %#v", s1.rules, s2.rules))
|
||||
}
|
||||
@ -52,11 +52,11 @@ func mustHaveSameRules(s1 Set, s2 Set) {
|
||||
|
||||
// HasRules returns true if and only if the receiving set has the given rules
|
||||
// instance as its rules.
|
||||
func (s Set) HasRules(rules Rules) bool {
|
||||
func (s Set[T]) HasRules(rules Rules[T]) bool {
|
||||
return s.rules.SameRules(rules)
|
||||
}
|
||||
|
||||
// Rules returns the receiving set's rules instance.
|
||||
func (s Set) Rules() Rules {
|
||||
func (s Set[T]) Rules() Rules[T] {
|
||||
return s.rules
|
||||
}
|
||||
|
Reference in New Issue
Block a user