-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a stream for non-cloneable iterators #37
Conversation
This definitely seems like a useful thing to have! |
@hawkw Yeah, it could be implemented outside the library but it is probably useful enough (and isn't trivial to implement) to warrant inclusion. I realize now that io::Chars has |
And one more thing as food for thought for anyone reading this. I used A problem with using |
To make sure I can release a stable 1.0 within a week or two I will hold of with this PR until shortly after 1.0 when I will put this and probably range streams in a 1.1-beta version where it can be better tested. |
e96ea04
to
9e74694
Compare
9e74694
to
e881074
Compare
5f9e1f4
to
2b8ed3c
Compare
Added a stream for non-cloneable iterators
This PR sketches out a possible implementation for a stream which do not directly support cloning. It does so by storing the tokens read from the iterator into a circular buffer which only allows for partial backtracking. Using this additional indirection iterators which cannot be cloned can be used as streams.
The performance drop using this stream type was measured to be about 20% for the JSON parser in the benches folder. Reading directly from a file or socket is not tested but it should work though the
chars
iterator onRead
(though it is currently unstable).I will hold on to merging this for a while as I would really appreciate some feedback on this as I do not intend to use this myself (and it needs documentation).
cc #30