12 // Set creates a set type with the given element Type.
14 // Set types are CollectionType implementations.
15 func Set(elem Type) Type {
23 // Equals returns true if the other Type is a set whose element type is
24 // equal to that of the receiver.
25 func (t typeSet) Equals(other Type) bool {
26 ot, isSet := other.typeImpl.(typeSet)
31 return t.ElementTypeT.Equals(ot.ElementTypeT)
34 func (t typeSet) FriendlyName(mode friendlyTypeNameMode) string {
35 elemName := t.ElementTypeT.friendlyNameMode(mode)
36 if mode == friendlyTypeConstraintName {
37 if t.ElementTypeT == DynamicPseudoType {
38 elemName = "any single type"
41 return "set of " + elemName
44 func (t typeSet) ElementType() Type {
48 func (t typeSet) GoString() string {
49 return fmt.Sprintf("cty.Set(%#v)", t.ElementTypeT)
52 // IsSetType returns true if the given type is a list type, regardless of its
54 func (t Type) IsSetType() bool {
55 _, ok := t.typeImpl.(typeSet)
59 // SetElementType is a convenience method that checks if the given type is
60 // a set type, returning a pointer to its element type if so and nil
61 // otherwise. This is intended to allow convenient conditional branches,
64 // if et := t.SetElementType(); et != nil {
65 // // Do something with *et
67 func (t Type) SetElementType() *Type {
68 if lt, ok := t.typeImpl.(typeSet); ok {
69 return <.ElementTypeT