Skip to content

Commit 4ec15ba

Browse files
committed
Add missing test and docstring to Passthrough
1 parent 6f6fddc commit 4ec15ba

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

iter/ops/unary.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func UnwrapResult[T any](r result.Result[T]) T {
1717
return r.Unwrap()
1818
}
1919

20+
// Passthrough may be used an an operation for iter.Map. It returns the
21+
// provided value without modification.
2022
func Passthrough[T any](t T) T {
2123
return t
2224
}

iter/ops/unary_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ func ExampleUnwrapResult() {
3838
// Output: [1 3 -6]
3939
}
4040

41+
func ExamplePassthrough() {
42+
numbers := iter.Map[int](iter.Lift([]int{1, 2, 3}), ops.Passthrough[int])
43+
44+
fmt.Println(iter.Collect[int](numbers))
45+
// Output: [1 2 3]
46+
}
47+
4148
func TestUnwrapOption(t *testing.T) {
4249
options := iter.Lift([]option.Option[int]{
4350
option.Some(4),

0 commit comments

Comments
 (0)