]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/zclconf/go-cty/cty/collection.go
update vendor and go.mod
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / zclconf / go-cty / cty / collection.go
CommitLineData
15c0b25d
AP
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)