Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for FromIterator (0.39 sec)

  1. test/typeparam/issue48598.go

    package main
    
    type Iterator[T any] interface {
    	Iterate()
    }
    
    type IteratorFunc[T any] func(fn func(T) bool)
    
    func (f IteratorFunc[T]) Iterate() {
    }
    
    func FromIterator[T any](it Iterator[T]) {
    	it.Iterate()
    }
    
    func Foo[T, R any]() {
    	FromIterator[R](IteratorFunc[R](nil))
    }
    
    func main() {
    	Foo[int, int]()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 01 19:45:34 UTC 2022
    - 475 bytes
    - Viewed (0)
  2. test/typeparam/issue48645b.go

    	f(fn)
    }
    
    type Stream[T any] struct {
    	it Iterator[T]
    }
    
    func (s Stream[T]) Iterate(fn func(T) bool) {
    	if s.it == nil {
    		return
    	}
    	s.it.Iterate(fn)
    }
    
    func FromIterator[T any](it Iterator[T]) Stream[T] {
    	return Stream[T]{it: it}
    }
    
    func (s Stream[T]) DropWhile(fn func(T) bool) Stream[T] {
    	return Pipe[T, T](s, func(t T) (T, bool) {
    		return t, true
    	})
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 01 19:45:34 UTC 2022
    - 1.4K bytes
    - Viewed (0)
Back to top