aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/zclconf/go-cty/cty/collection.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/zclconf/go-cty/cty/collection.go')
-rw-r--r--vendor/github.com/zclconf/go-cty/cty/collection.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/github.com/zclconf/go-cty/cty/collection.go b/vendor/github.com/zclconf/go-cty/cty/collection.go
new file mode 100644
index 0000000..ab3919b
--- /dev/null
+++ b/vendor/github.com/zclconf/go-cty/cty/collection.go
@@ -0,0 +1,34 @@
1package cty
2
3import (
4 "errors"
5)
6
7type 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.
13func (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.
21func (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.
34type ElementCallback func(key Value, val Value) (stop bool)