From e0b1bdca5b56a104d8c221cb3bbb7eb16b5fcec4 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 19 May 2013 12:06:39 -0700 Subject: [PATCH 1/3] Add additional documentation in core::io. Added docs for stdout, stderr, print, and println. --- src/libcore/io.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 77b486ca44619..820d810a36f8c 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1561,13 +1561,55 @@ 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 +* ~~~ +* core::io::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 +* ~~~ +* core::io::println("hello"); +* ~~~ +*/ pub fn println(s: &str) { stdout().write_line(s); } From 929050de73c1edb22211fa05e891068fe9a1a0d2 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 19 May 2013 12:42:00 -0700 Subject: [PATCH 2/3] Added note about prelude inclusion. --- src/libcore/io.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 820d810a36f8c..feceb9f4b17d7 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1593,7 +1593,8 @@ pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) } * * # Examples * ~~~ -* core::io::print("hello"); +* // print is imported into the prelude, and so is always available. +* print("hello"); * ~~~ */ pub fn print(s: &str) { @@ -1607,7 +1608,8 @@ pub fn print(s: &str) { * * # Examples * ~~~ -* core::io::println("hello"); +* // println is imported into the prelude, and so is always available. +* println("hello"); * ~~~ */ pub fn println(s: &str) { From 58777272857526eb301bfedd909e6826e5edf716 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 19 May 2013 15:31:19 -0700 Subject: [PATCH 3/3] Fix trailing whitespace --- src/libcore/io.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index feceb9f4b17d7..2060964173d37 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1587,7 +1587,7 @@ 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`. * @@ -1603,7 +1603,7 @@ pub fn print(s: &str) { /** * Prints a string to standard output, followed by a newline. -* +* * If you do not want an implicit newline, please see `print`. * * # Examples