-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
76 lines (57 loc) · 2 KB
/
types.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package g
import (
"iter"
"os"
)
type (
// Result is a generic struct for representing a result value along with an error.
Result[T any] struct {
value *T // Pointer to the value.
err error // Associated error.
}
// Option is a generic struct for representing an optional value.
Option[T any] struct {
value *T // Pointer to the value.
}
// File is a struct that represents a file along with an iterator for reading lines.
File struct {
file *os.File // Underlying os.File.
name String // File name.
guard bool // Guard indicates whether the file is protected against concurrent access.
}
// Dir is a struct representing a directory path.
Dir struct {
path String // Directory path.
}
// String is an alias for the string type.
String string
// Int is an alias for the int type.
Int int
// Float is an alias for the float64 type.
Float float64
// Bytes is an alias for the []byte type.
Bytes []byte
// Slice is a generic alias for a slice.
Slice[T any] []T
// Map is a generic alias for a map.
Map[K comparable, V any] map[K]V
// Set is a generic alias for a set implemented using a map.
Set[T comparable] map[T]struct{}
// Pair is a struct representing a key-value Pair for MapOrd.
Pair[K, V any] struct {
Key K // Key of the pair.
Value V // Value associated with the key.
}
// MapOrd is a generic alias for a slice of ordered key-value pairs.
MapOrd[K, V any] []Pair[K, V]
// SeqSet is an iterator over sequences of unique values.
SeqSet[V comparable] iter.Seq[V]
// SeqSlice is an iterator over sequences of individual values.
SeqSlice[V any] iter.Seq[V]
// SeqSlices is an iterator over slices of sequences of individual values.
SeqSlices[V any] iter.Seq[[]V]
// SeqMapOrd is an iterator over sequences of ordered pairs of values, most commonly ordered key-value pairs.
SeqMapOrd[K, V any] iter.Seq2[K, V]
// SeqMap is an iterator over sequences of pairs of values, most commonly key-value pairs.
SeqMap[K comparable, V any] iter.Seq2[K, V]
)