Documentation
¶
Overview ¶
Package pair provides a generic Pair type for representing pairs of values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pair ¶
Pair is a pair of values.
Pair is commonly used with iterators for operations like Zip and Enumerate, as well as with Option for Zip and Unzip operations.
Examples ¶
// Create a pair
p := pair.Pair[int, string]{A: 42, B: "hello"}
a, b := p.Split()
fmt.Println(a, b) // Output: 42 hello
// Use with iterators
iter1 := iterator.FromSlice([]int{1, 2, 3})
iter2 := iterator.FromSlice([]string{"a", "b", "c"})
zipped := iterator.Zip(iter1, iter2)
for opt := zipped.Next(); opt.IsSome(); opt = zipped.Next() {
p := opt.Unwrap()
fmt.Println(p.A, p.B) // Output: 1 a, 2 b, 3 c
}
Click to show internal directories.
Click to hide internal directories.