Skip to content

Commit 4a288bc

Browse files
committed
Explain EOF behavior in File.eof().
Fies rust-lang#16239.
1 parent 776c17f commit 4a288bc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libstd/io/fs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,15 @@ impl File {
236236
})
237237
}
238238

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

0 commit comments

Comments
 (0)