]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/zclconf/go-cty/cty/collection.go
Merge pull request #27 from terraform-providers/go-modules-2019-02-22
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / zclconf / go-cty / cty / collection.go
1 package cty
2
3 import (
4 "errors"
5 )
6
7 type collectionTypeImpl interface {
8 ElementType() Type
9 }
10
11 // IsCollectionType returns true if the given type supports the operations
12 // that are defined for all collection types.
13 func (t Type) IsCollectionType() bool {
14 _, ok := t.typeImpl.(collectionTypeImpl)
15 return ok
16 }
17
18 // ElementType returns the element type of the receiver if it is a collection
19 // type, or panics if it is not. Use IsCollectionType first to test whether
20 // this method will succeed.
21 func (t Type) ElementType() Type {
22 if ct, ok := t.typeImpl.(collectionTypeImpl); ok {
23 return ct.ElementType()
24 }
25 panic(errors.New("not a collection type"))
26 }
27
28 // ElementCallback is a callback type used for iterating over elements of
29 // collections and attributes of objects.
30 //
31 // The types of key and value depend on what type is being iterated over.
32 // Return true to stop iterating after the current element, or false to
33 // continue iterating.
34 type ElementCallback func(key Value, val Value) (stop bool)