about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-05-19 23:13:36 -0700
committerbors <bors@rust-lang.org>2013-05-19 23:13:36 -0700
commitd019e145c033ac60d4413321da21d3e877b4b786 (patch)
tree54f2fd4f689e36bbafd0e6875eae6258770e11ae
parent3a481c0f88025318eba7c48907a5c1d966e01d27 (diff)
parentdcc2879266ee6e733a4729b425da0ff25aeebd1f (diff)
downloadrust-d019e145c033ac60d4413321da21d3e877b4b786.tar.gz
rust-d019e145c033ac60d4413321da21d3e877b4b786.zip
auto merge of #6621 : steveklabnik/rust/expand_reader_docs, r=thestinger
Had a conversation with @cmr in IRC about some places that these
docs were confusing. The functions that advance the stream now say so.

In addition, I think that calling out the similarities to familliar C
functions should help people coming from other languages.
-rw-r--r--src/libcore/io.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 7d76d8d30cd..98bc7be3666 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -114,14 +114,16 @@ pub trait Reader {
 
     // FIXME (#2982): This should probably return an error.
     /**
-    * Reads bytes and puts them into `bytes`. Returns the number of
-    * bytes read.
+    * Reads bytes and puts them into `bytes`, advancing the cursor. Returns the
+    * number of bytes read.
     *
     * The number of bytes to be read is `len` or the end of the file,
     * whichever comes first.
     *
     * The buffer must be at least `len` bytes long.
     *
+    * `read` is conceptually similar to C's `fread` function.
+    *
     * # Examples
     *
     * None right now.
@@ -129,10 +131,12 @@ pub trait Reader {
     fn read(&self, bytes: &mut [u8], len: uint) -> uint;
 
     /**
-    * Reads a single byte.
+    * Reads a single byte, advancing the cursor.
     *
     * In the case of an EOF or an error, returns a negative value.
     *
+    * `read_byte` is conceptually similar to C's `getc` function.
+    *
     * # Examples
     *
     * None right now.
@@ -142,6 +146,8 @@ pub trait Reader {
     /**
     * Returns a boolean value: are we currently at EOF?
     *
+    * `eof` is conceptually similar to C's `feof` function.
+    *
     * # Examples
     *
     * None right now.
@@ -154,6 +160,8 @@ pub trait Reader {
     * Takes an optional SeekStyle, which affects how we seek from the
     * position. See `SeekStyle` docs for more details.
     *
+    * `seek` is conceptually similar to C's `fseek` function.
+    *
     * # Examples
     *
     * None right now.
@@ -163,6 +171,8 @@ pub trait Reader {
     /**
     * Returns the current position within the stream.
     *
+    * `tell` is conceptually similar to C's `ftell` function.
+    *
     * # Examples
     *
     * None right now.