Skip to content

Commit d019e14

Browse files
committed
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.
2 parents 3a481c0 + dcc2879 commit d019e14

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/libcore/io.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,29 @@ pub trait Reader {
114114

115115
// FIXME (#2982): This should probably return an error.
116116
/**
117-
* Reads bytes and puts them into `bytes`. Returns the number of
118-
* bytes read.
117+
* Reads bytes and puts them into `bytes`, advancing the cursor. Returns the
118+
* number of bytes read.
119119
*
120120
* The number of bytes to be read is `len` or the end of the file,
121121
* whichever comes first.
122122
*
123123
* The buffer must be at least `len` bytes long.
124124
*
125+
* `read` is conceptually similar to C's `fread` function.
126+
*
125127
* # Examples
126128
*
127129
* None right now.
128130
*/
129131
fn read(&self, bytes: &mut [u8], len: uint) -> uint;
130132

131133
/**
132-
* Reads a single byte.
134+
* Reads a single byte, advancing the cursor.
133135
*
134136
* In the case of an EOF or an error, returns a negative value.
135137
*
138+
* `read_byte` is conceptually similar to C's `getc` function.
139+
*
136140
* # Examples
137141
*
138142
* None right now.
@@ -142,6 +146,8 @@ pub trait Reader {
142146
/**
143147
* Returns a boolean value: are we currently at EOF?
144148
*
149+
* `eof` is conceptually similar to C's `feof` function.
150+
*
145151
* # Examples
146152
*
147153
* None right now.
@@ -154,6 +160,8 @@ pub trait Reader {
154160
* Takes an optional SeekStyle, which affects how we seek from the
155161
* position. See `SeekStyle` docs for more details.
156162
*
163+
* `seek` is conceptually similar to C's `fseek` function.
164+
*
157165
* # Examples
158166
*
159167
* None right now.
@@ -163,6 +171,8 @@ pub trait Reader {
163171
/**
164172
* Returns the current position within the stream.
165173
*
174+
* `tell` is conceptually similar to C's `ftell` function.
175+
*
166176
* # Examples
167177
*
168178
* None right now.

0 commit comments

Comments
 (0)