Skip to content

Add additional documentation in core::io. #6619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/libcore/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1561,13 +1561,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);
}
Expand Down