-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathall_types.go
More file actions
33 lines (31 loc) · 827 Bytes
/
Copy pathall_types.go
File metadata and controls
33 lines (31 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package dscope
import (
"iter"
"reflect"
)
func (s Scope) AllTypes() iter.Seq[reflect.Type] {
return func(yield func(reflect.Type) bool) {
if !yield(reflect.TypeFor[InjectStruct]()) {
return
}
if !yield(reflect.TypeFor[Fork]()) {
return
}
if !yield(reflect.TypeFor[Reset]()) {
return
}
for value := range s.values.IterValues() {
// Always-provided types (e.g. InjectStruct, Fork, Reset) are emitted above as
// built-ins. They may also appear in s.values if a user provides a
// definition for them, but Scope.get ignores such definitions and
// always returns the built-in. Skip them here to avoid yielding the
// same type more than once.
if isAlwaysProvided(value.typeInfo.TypeID) {
continue
}
if !yield(typeIDToType(value.typeInfo.TypeID)) {
return
}
}
}
}