aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/google/go-cmp/cmp/internal/function
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/google/go-cmp/cmp/internal/function
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/google/go-cmp/cmp/internal/function')
-rw-r--r--vendor/github.com/google/go-cmp/cmp/internal/function/func.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/github.com/google/go-cmp/cmp/internal/function/func.go b/vendor/github.com/google/go-cmp/cmp/internal/function/func.go
new file mode 100644
index 0000000..4c35ff1
--- /dev/null
+++ b/vendor/github.com/google/go-cmp/cmp/internal/function/func.go
@@ -0,0 +1,49 @@
1// Copyright 2017, The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE.md file.
4
5// Package function identifies function types.
6package function
7
8import "reflect"
9
10type funcType int
11
12const (
13 _ funcType = iota
14
15 ttbFunc // func(T, T) bool
16 tibFunc // func(T, I) bool
17 trFunc // func(T) R
18
19 Equal = ttbFunc // func(T, T) bool
20 EqualAssignable = tibFunc // func(T, I) bool; encapsulates func(T, T) bool
21 Transformer = trFunc // func(T) R
22 ValueFilter = ttbFunc // func(T, T) bool
23 Less = ttbFunc // func(T, T) bool
24)
25
26var boolType = reflect.TypeOf(true)
27
28// IsType reports whether the reflect.Type is of the specified function type.
29func IsType(t reflect.Type, ft funcType) bool {
30 if t == nil || t.Kind() != reflect.Func || t.IsVariadic() {
31 return false
32 }
33 ni, no := t.NumIn(), t.NumOut()
34 switch ft {
35 case ttbFunc: // func(T, T) bool
36 if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == boolType {
37 return true
38 }
39 case tibFunc: // func(T, I) bool
40 if ni == 2 && no == 1 && t.In(0).AssignableTo(t.In(1)) && t.Out(0) == boolType {
41 return true
42 }
43 case trFunc: // func(T) R
44 if ni == 1 && no == 1 {
45 return true
46 }
47 }
48 return false
49}