func (stream *TokenStream) ToSlice() ([]*Token, error) {
	var result []*Token
	for stream.Scan() {
		result = append(result, stream.Token())
	}
	if err := stream.Err(); err != nil {
		return nil, stream.Err()
	}
	return result, nil
}
ToSlice converts the Tokens iterator into a slice (array). Calling ToSlice will exhaust the iterator. For big files, putting everything into an array may cause memory pressure.
package jargon
import (
	"io"
	"strings"
)
type Filter func(*TokenStream) *TokenStream
type TokenStream struct {
	next func() (*Token, error)
	token *Token  
	err   error   
}
func (stream *TokenStream) Next() (*Token, error) {
	return stream.next()
}
func NewTokenStream(next func() (*Token, error)) *TokenStream {
	stream := &TokenStream{}
	wrapper := func() (*Token, error) {
		stream.token, stream.err = next()
		return stream.Token(), stream.Err()
	}
	stream.next = wrapper
	return stream
}
func (stream *TokenStream) Scan() bool {
	stream.token, stream.err = stream.Next()
	return stream.token != nil && stream.err == nil
}
func (stream *TokenStream) Token() *Token {
	return stream.token
}
func (stream *TokenStream) Err() error {
	return stream.err
}
type where struct {
	stream    *TokenStream
	predicate func(*Token) bool
}
func (stream *TokenStream) Where(predicate func(*Token) bool) *TokenStream {
	w := &where{
		stream:    stream,
		predicate: predicate,
	}
	return NewTokenStream(w.next)
}
func (w *where) next() (*Token, error) {
	for {
		token, err := w.stream.Next()
		if err != nil {
			return nil, err
		}
		if token == nil {
			break
		}
		if w.predicate(token) {
			return token, nil
		}
	}
	return nil, nil
}