Debian Codegraph @

common/types/traits/traits.go

raw symbols SCIP
1 // Copyright 2018 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Package traits defines interfaces that a type may implement to participate
16 // in operator overloads and function dispatch.
17 package traits
18
19 const (
20 // AdderType types provide a '+' operator overload.
21 AdderType = 1 << iota
22
23 // ComparerType types support ordering comparisons '<', '<=', '>', '>='.
24 ComparerType
25
26 // ContainerType types support 'in' operations.
27 ContainerType
28
29 // DividerType types support '/' operations.
30 DividerType
31
32 // FieldTesterType types support the detection of field value presence.
33 FieldTesterType
34
35 // IndexerType types support index access with dynamic values.
36 IndexerType
37
38 // IterableType types can be iterated over in comprehensions.
39 IterableType
40
41 // IteratorType types support iterator semantics.
42 IteratorType
43
44 // MatcherType types support pattern matching via 'matches' method.
45 MatcherType
46
47 // ModderType types support modulus operations '%'
48 ModderType
49
50 // MultiplierType types support '*' operations.
51 MultiplierType
52
53 // NegatorType types support either negation via '!' or '-'
54 NegatorType
55
56 // ReceiverType types support dynamic dispatch to instance methods.
57 ReceiverType
58
59 // SizerType types support the size() method.
60 SizerType
61
62 // SubtractorType types support '-' operations.
63 SubtractorType
64
65 // FoldableType types support comprehensions v2 macros which iterate over (key, value) pairs.
66 FoldableType
67 )
68
69 const (
70 // ListerType supports a set of traits necessary for list operations.
71 //
72 // The ListerType is syntactic sugar and not intended to be a perfect reflection of all List operators.
73 ListerType = AdderType | ContainerType | IndexerType | IterableType | SizerType
74
75 // MapperType supports a set of traits necessary for map operations.
76 //
77 // The MapperType is syntactic sugar and not intended to be a perfect reflection of all Map operators.
78 MapperType = ContainerType | IndexerType | IterableType | SizerType
79 )