github.com/pulumi/terraform@v1.4.0/pkg/addrs/unique_key.go (about) 1 package addrs 2 3 // UniqueKey is an interface implemented by values that serve as unique map 4 // keys for particular addresses. 5 // 6 // All implementations of UniqueKey are comparable and can thus be used as 7 // map keys. Unique keys generated from different address types are always 8 // distinct. All functionally-equivalent keys for the same address type 9 // always compare equal, and likewise functionally-different values do not. 10 type UniqueKey interface { 11 uniqueKeySigil() 12 } 13 14 // UniqueKeyer is an interface implemented by types that can be represented 15 // by a unique key. 16 // 17 // Some address types naturally comply with the expectations of a UniqueKey 18 // and may thus be their own unique key type. However, address types that 19 // are not naturally comparable can implement this interface by returning 20 // proxy values. 21 type UniqueKeyer interface { 22 UniqueKey() UniqueKey 23 } 24 25 func Equivalent[T UniqueKeyer](a, b T) bool { 26 return a.UniqueKey() == b.UniqueKey() 27 }