func Drain[T any](ch <-chan T) []T {
	var ret []T
	for {
		select {
		case item, ok := <-ch:
			if !ok {
				return ret
			}
			ret = append(ret, item)
		default:
			return ret
		}
	}
}
// Drain fetches all buffered items from a channel and returns them as a slice.
Drain fetches all buffered items from a channel and returns them as a slice.
// Drain fetches all buffered items from a channel and returns them as a slice .
func Drain[T any](ch <-chan T) []T {
	var ret []T
	for {
		select {
		case item, ok := <-ch:
			if !ok {
				return ret
			}
			ret = append(ret, item)
		default:
			return ret
		}
	}
}
func Drain [ T any ] ( ch <- chan T ) [ ] T { var ret [ ] T for { select { case item , ok := <- ch : if ! ok { return ret } ret = append ( ret , item ) default : return ret } } }
Drain fetches all buffered items from a channel and returns them as a slice.
Drain fetches all buffered items from a channel and returns them as a slice .