auto merge of #6619 : steveklabnik/rust/stdout_docs, r=thestinger

Added docs for stdout, stderr, print, and println.
This commit is contained in:
bors 2013-05-19 18:22:33 -07:00
commit 9283dfe0b4

View file

@ -1571,13 +1571,57 @@ pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> {
// FIXME (#2004) it would be great if this could be a const
// FIXME (#2004) why are these different from the way stdin() is
// implemented?
/**
* Gives a `Writer` which allows you to write to the standard output.
*
* # Examples
* ~~~
* let stdout = core::io::stdout();
* stdout.write_str("hello\n");
* ~~~
*/
pub fn stdout() -> @Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
/**
* Gives a `Writer` which allows you to write to standard error.
*
* # Examples
* ~~~
* let stderr = core::io::stderr();
* stderr.write_str("hello\n");
* ~~~
*/
pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
/**
* Prints a string to standard output.
*
* This string will not have an implicit newline at the end. If you want
* an implicit newline, please see `println`.
*
* # Examples
* ~~~
* // print is imported into the prelude, and so is always available.
* print("hello");
* ~~~
*/
pub fn print(s: &str) {
stdout().write_str(s);
}
/**
* Prints a string to standard output, followed by a newline.
*
* If you do not want an implicit newline, please see `print`.
*
* # Examples
* ~~~
* // println is imported into the prelude, and so is always available.
* println("hello");
* ~~~
*/
pub fn println(s: &str) {
stdout().write_line(s);
}