@@ -84,25 +84,29 @@ pub trait Reader {
84
84
85
85
// FIXME (#2982): This should probably return an error.
86
86
/**
87
- * Reads bytes and puts them into `bytes`. Returns the number of
88
- * bytes read.
87
+ * Reads bytes and puts them into `bytes`, advancing the cursor. Returns the
88
+ * number of bytes read.
89
89
*
90
90
* The number of bytes to be read is `len` or the end of the file,
91
91
* whichever comes first.
92
92
*
93
93
* The buffer must be at least `len` bytes long.
94
94
*
95
+ * `read` is conceptually similar to C's `fread`.
96
+ *
95
97
* # Examples
96
98
*
97
99
* None right now.
98
100
*/
99
101
fn read ( & self , bytes : & mut [ u8 ] , len : uint ) -> uint ;
100
102
101
103
/**
102
- * Reads a single byte.
104
+ * Reads a single byte, advancing the cursor .
103
105
*
104
106
* In the case of an EOF or an error, returns a negative value.
105
107
*
108
+ * `read_byte` is conceptually similar to C's `getc` function.
109
+ *
106
110
* # Examples
107
111
*
108
112
* None right now.
@@ -112,6 +116,8 @@ pub trait Reader {
112
116
/**
113
117
* Returns a boolean value: are we currently at EOF?
114
118
*
119
+ * `eof` is conceptually similar to C's `feof` function.
120
+ *
115
121
* # Examples
116
122
*
117
123
* None right now.
@@ -124,6 +130,8 @@ pub trait Reader {
124
130
* Takes an optional SeekStyle, which affects how we seek from the
125
131
* position. See `SeekStyle` docs for more details.
126
132
*
133
+ * `seek` is conceptually similar to C's `fseek`.
134
+ *
127
135
* # Examples
128
136
*
129
137
* None right now.
@@ -133,6 +141,8 @@ pub trait Reader {
133
141
/**
134
142
* Returns the current position within the stream.
135
143
*
144
+ * `tell` is conceptually similar to C's `ftell` function.
145
+ *
136
146
* # Examples
137
147
*
138
148
* None right now.
@@ -1561,57 +1571,13 @@ pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> {
1561
1571
// FIXME (#2004) it would be great if this could be a const
1562
1572
// FIXME (#2004) why are these different from the way stdin() is
1563
1573
// implemented?
1564
-
1565
-
1566
- /**
1567
- * Gives a `Writer` which allows you to write to the standard output.
1568
- *
1569
- * # Examples
1570
- * ~~~
1571
- * let stdout = core::io::stdout();
1572
- * stdout.write_str("hello\n " ) ;
1573
- * ~~~
1574
- * /
1575
1574
pub fn stdout() -> @Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
1576
-
1577
- /**
1578
- * Gives a `Writer` which allows you to write to standard error.
1579
- *
1580
- * # Examples
1581
- * ~~~
1582
- * let stderr = core::io::stderr();
1583
- * stderr.write_str("hello\n");
1584
- * ~~~
1585
- */
1586
1575
pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
1587
1576
1588
- /**
1589
- * Prints a string to standard output.
1590
- *
1591
- * This string will not have an implicit newline at the end. If you want
1592
- * an implicit newline, please see `println`.
1593
- *
1594
- * # Examples
1595
- * ~~~
1596
- * // print is imported into the prelude, and so is always available.
1597
- * print("hello");
1598
- * ~~~
1599
- */
1600
1577
pub fn print(s: &str) {
1601
1578
stdout().write_str(s);
1602
1579
}
1603
1580
1604
- /**
1605
- * Prints a string to standard output, followed by a newline.
1606
- *
1607
- * If you do not want an implicit newline, please see `print`.
1608
- *
1609
- * # Examples
1610
- * ~~~
1611
- * // println is imported into the prelude, and so is always available.
1612
- * println("hello");
1613
- * ~~~
1614
- */
1615
1581
pub fn println(s: &str) {
1616
1582
stdout().write_line(s);
1617
1583
}
0 commit comments