7 // TypeList instances represent specific list types. Each distinct ElementType
8 // creates a distinct, non-equal list type.
14 // List creates a map type with the given element Type.
16 // List types are CollectionType implementations.
17 func List(elem Type) Type {
25 // Equals returns true if the other Type is a list whose element type is
26 // equal to that of the receiver.
27 func (t typeList) Equals(other Type) bool {
28 ot, isList := other.typeImpl.(typeList)
33 return t.ElementTypeT.Equals(ot.ElementTypeT)
36 func (t typeList) 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 "list of " + elemName
46 func (t typeList) ElementType() Type {
50 func (t typeList) GoString() string {
51 return fmt.Sprintf("cty.List(%#v)", t.ElementTypeT)
54 // IsListType returns true if the given type is a list type, regardless of its
56 func (t Type) IsListType() bool {
57 _, ok := t.typeImpl.(typeList)
61 // ListElementType is a convenience method that checks if the given type is
62 // a list 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.ListElementType(); et != nil {
67 // // Do something with *et
69 func (t Type) ListElementType() *Type {
70 if lt, ok := t.typeImpl.(typeList); ok {
71 return <.ElementTypeT