-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
io::reader::read_byte for *FILE behaves surprisingly on EOF #2960
Comments
This came up with https://gist.github.com/8f81d3e2b39f31cca1cc -- maybe the real issue is that |
java.lang.Scanner uses hasNext() to say whether or not the file has anymore contents. Why not keep io::reader.eof for its low-level impl and add io::reader.has_next for that use case? |
Since that gist is mine, I'd like to say that I find it odd I had to do a cast to get it in a format that is usable to convert to a str. I'd like read_str to return a u8 just to avoid the cast operation which feels inefficient to me. |
still legit but still, I suspect, likely to be absorbed in the IO rewrite. Any day now. |
New IO should solve this problem, but if you add a test, you can close this :-) |
This code has long since been purged, closing. |
Restore test filtering by substring. Previously it was only looking for tests whose path was a prefix of the given filter fixes rust-lang#2958
In the
io::reader
impl for*libc::FILE
,read_byte
returns -1 on EOF. This is not surprising since it just callslibc::fgetc
, but it's arguably wrong since callers are presumably going to useeof()
to check for EOF and thus shouldn't have to worry about dealing with a bogus trailing -1.Instead, perhaps it could fail? I'm not really sure. Or maybe this is supposed to be a low-level interface, but it still seems weird for Rust code to have to deal with sentinel values like this.
The text was updated successfully, but these errors were encountered: