You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add fn skip(n: uint) with a default implementation to Reader #13989
This seems useful though reader does have a few methods on it already. I'm wondering what @alexcrichton thinks?
Edit: I'm not sure if this is a worthwhile change anymore. We can easily to reader.read_exact(n) to achieve the same thing.
I'm worried about adding more methods to readers that downstream consumers need to consider to override. Having one flush() method is unfortunate, and I think time should be taken to consider whether this is justified to add it or not.
I don't think that we can quite use read_exact for this because in theory skip doesn't actually have to read any data. It does sound quite similar to seek though...
The problem is that given today's (and likely future) coherence rules, you cannot create a trait that uses Seek if available but otherwise falls back to a less efficient Reader:
This is actually a decent motivating use-case for allowing an implementation of a trait to refine an existing implementation defined on a superset of types.
@alexcrichton it is true that having too many random convenience methods can be a problem, but I think that it makes sense to add methods for operations that can be implemented much more efficiently in some contexts than others. In other words, while skip is technically implementable as a read, there is a big efficiency difference between a call to fseek and reading tons of bytes.
In today's day and age this sort of addition (to a core trait like Read) will require an RFC, so I'm going to close this in favor of that course of action.
Activity
pongad commentedon May 14, 2014
This seems useful though reader does have a few methods on it already. I'm wondering what @alexcrichton thinks?
Edit: I'm not sure if this is a worthwhile change anymore. We can easily to
reader.read_exact(n)to achieve the same thing.alexcrichton commentedon May 14, 2014
I'm worried about adding more methods to readers that downstream consumers need to consider to override. Having one
flush()method is unfortunate, and I think time should be taken to consider whether this is justified to add it or not.I don't think that we can quite use
read_exactfor this because in theoryskipdoesn't actually have to read any data. It does sound quite similar toseekthough...nox commentedon Jul 11, 2014
Any news on this? I'm writing an IFF reader and I want users to be able to skip chunk bodies, requiring Seek for just this seems overkill.
wycats commentedon Jul 20, 2014
The problem is that given today's (and likely future) coherence rules, you cannot create a trait that uses
Seekif available but otherwise falls back to a less efficientReader:This is actually a decent motivating use-case for allowing an implementation of a trait to refine an existing implementation defined on a superset of types.
wycats commentedon Jul 20, 2014
@pongad I do not think
read_exactis appropriate, since it requires allocating a buffer ofnsize even if the backend supports efficient skipping.nikomatsakis commentedon Aug 6, 2014
@alexcrichton it is true that having too many random convenience methods can be a problem, but I think that it makes sense to add methods for operations that can be implemented much more efficiently in some contexts than others. In other words, while
skipis technically implementable as a read, there is a big efficiency difference between a call tofseekand reading tons of bytes.Add a new method skip(n: uint) to std::io::Reader.
Add skip(n: uint) to Seek, File and BufferedReader.
steveklabnik commentedon Feb 14, 2015
@carllerche did this end up getting addressed in io reform?
carllerche commentedon Feb 14, 2015
@steveklabnik Not yet. I think (hope) it is coming pre 1.0 though. cc @aturon
aturon commentedon Feb 16, 2015
Nominating for 1.0-beta P-high. (Should be trivial.)
pnkfelix commentedon Feb 19, 2015
P-high, I-needs-decision (not 1.0 beta blocker)
alexcrichton commentedon Jan 21, 2016
In today's day and age this sort of addition (to a core trait like
Read) will require an RFC, so I'm going to close this in favor of that course of action.youknowone commentedon Apr 21, 2021
#53294
Auto merge of rust-lang#13989 - Veykril:hover, r=Veykril
change `literal_string_with_formatting_args` lint category to nursery (…
change `literal_string_with_formatting_args` lint category to nursery (…
change `literal_string_with_formatting_args` lint category to nursery (…