Skip to content

Commit 9283dfe

Browse files
committed
auto merge of #6619 : steveklabnik/rust/stdout_docs, r=thestinger
Added docs for stdout, stderr, print, and println.
2 parents 7396f7f + 5877727 commit 9283dfe

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/libcore/io.rs

+44
Original file line numberDiff line numberDiff line change
@@ -1571,13 +1571,57 @@ pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> {
15711571
// FIXME (#2004) it would be great if this could be a const
15721572
// FIXME (#2004) why are these different from the way stdin() is
15731573
// implemented?
1574+
1575+
1576+
/**
1577+
* Gives a `Writer` which allows you to write to the standard output.
1578+
*
1579+
* # Examples
1580+
* ~~~
1581+
* let stdout = core::io::stdout();
1582+
* stdout.write_str("hello\n");
1583+
* ~~~
1584+
*/
15741585
pub fn stdout() -> @Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
1586+
1587+
/**
1588+
* Gives a `Writer` which allows you to write to standard error.
1589+
*
1590+
* # Examples
1591+
* ~~~
1592+
* let stderr = core::io::stderr();
1593+
* stderr.write_str("hello\n");
1594+
* ~~~
1595+
*/
15751596
pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
15761597

1598+
/**
1599+
* Prints a string to standard output.
1600+
*
1601+
* This string will not have an implicit newline at the end. If you want
1602+
* an implicit newline, please see `println`.
1603+
*
1604+
* # Examples
1605+
* ~~~
1606+
* // print is imported into the prelude, and so is always available.
1607+
* print("hello");
1608+
* ~~~
1609+
*/
15771610
pub fn print(s: &str) {
15781611
stdout().write_str(s);
15791612
}
15801613

1614+
/**
1615+
* Prints a string to standard output, followed by a newline.
1616+
*
1617+
* If you do not want an implicit newline, please see `print`.
1618+
*
1619+
* # Examples
1620+
* ~~~
1621+
* // println is imported into the prelude, and so is always available.
1622+
* println("hello");
1623+
* ~~~
1624+
*/
15811625
pub fn println(s: &str) {
15821626
stdout().write_line(s);
15831627
}

0 commit comments

Comments
 (0)