7 // TypeList instances represent specific list types. Each distinct ElementType
8 // creates a distinct, non-equal list type.
14 // Map creates a map type with the given element Type.
16 // Map types are CollectionType implementations.
17 func Map(elem Type) Type {
25 // Equals returns true if the other Type is a map whose element type is
26 // equal to that of the receiver.
27 func (t typeMap) Equals(other Type) bool {
28 ot, isMap := other.typeImpl.(typeMap)
33 return t.ElementTypeT.Equals(ot.ElementTypeT)
36 func (t typeMap) FriendlyName(mode friendlyTypeNameMode) string {
37 elemName := t.ElementTypeT.friendlyNameMode(mode)
38 if mode == friendlyTypeConstraintName {
39 if t.ElementTypeT == DynamicPseudoType {
40 elemName = "any single type"
43 return "map of " + elemName
46 func (t typeMap) ElementType() Type {
50 func (t typeMap) GoString() string {
51 return fmt.Sprintf("cty.Map(%#v)", t.ElementTypeT)
54 // IsMapType returns true if the given type is a list type, regardless of its
56 func (t Type) IsMapType() bool {
57 _, ok := t.typeImpl.(typeMap)
61 // MapElementType is a convenience method that checks if the given type is
62 // a map type, returning a pointer to its element type if so and nil
63 // otherwise. This is intended to allow convenient conditional branches,
66 // if et := t.MapElementType(); et != nil {
67 // // Do something with *et
69 func (t Type) MapElementType() *Type {
70 if lt, ok := t.typeImpl.(typeMap); ok {
71 return <.ElementTypeT