Uh oh!
There was an error while loading. Please reload this page.
RFC: Add size hint methods on Reader and Writer - #46
Conversation
alexcrichton
commented
Apr 15, 2014
One thing I'd be a little worried about is how wordy writer wrappers will become. When a type wraps an inner writer, it already has to remember to override I personally think that this belongs as a separate trait because most writers aren't pre-allocating space. Essentially |
thestinger
commented
Apr 15, 2014
Pre-allocating space is also important when writing to the disk. If |
SimonSapin
commented
Apr 17, 2014
If a writer wrapper forgets to override
This doesn’t really work for generic code that wants to accept any writer. The point is to provide this information to the writer, and leave it to the implementation to decide what to do with it (if anything). If this is a separate trait, a writer that doesn’t do anything with this information would still need to implement the trait in order to be used with code that provides this information. |
SimonSapin
commented
Apr 29, 2014
I suppose a separate trait would work if we have "specialization" (rust-lang/rust#7059). |
* Add size_hint on Reader, like on Iterator * Highlight the precedent of Iterator::size_hint * Rename reserve_additional to reserve * Use an estimated range (lower bound and optional upper bound) like size_hint, rather than a single estimated number.
SimonSapin
commented
Apr 29, 2014
I just pushed an update. The text is almost completely rewritten, but the spirit is the same. The main changes are:
|
brson
commented
Jun 11, 2014
Discussed at https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-06-10, the feeling is that none of us have seen precedent for these operations in other I/O libraries and we don't want to risk breaking the mold here. Not accepted. Sorry. |
SimonSapin
commented
Jun 19, 2014
Unfortunately it seems that no one was "championing" this RFC when it was discussed. I accept the team’s decision, but just for my curiosity: was there a precedent for the |
brson
commented
Jun 19, 2014
@SimonSapin I don't know if there is precedent for iterator size hints. @thestinger might know. |
thestinger
commented
Jun 19, 2014
Python has a size hint for iterators, and Rust's size hint was inspired by that feature. I altered it to provide both a lower bound and optional upper bound, because Python's flexible definition can be problematic: |
Add missing backtick
Registry / Container reform
No description provided.