Skip to content

Explain EOF behavior in File.eof(). #16578

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

Merged
merged 1 commit into from
Aug 18, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,15 @@ impl File {
})
}

/// Tests whether this stream has reached EOF.
/// Returns true if the stream has reached the end of the file.
///
/// If true, then this file will no longer continue to return data via
/// `read`.
///
/// Note that the operating system will not return an `EOF` indicator
/// until you have attempted to read past the end of the file, so if
/// you've read _exactly_ the number of bytes in the file, this will
/// return `false`, not `true`.
pub fn eof(&self) -> bool {
self.last_nread == 0
}
Expand Down