Skip to content
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

add puts() to libstd and the prelude #9361

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions src/libstd/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,22 @@ pub fn println(s: &str) {
stdout().write_line(s);
}

/**
* Prints every object that implements the ToStr trait to standard output, followed by a newline.
*
* It works like, eg, ruby's puts.
*
* # Example
*
* ~~~ {.rust}
* // puts is imported into the prelude, and so is always available.
* puts(3u);
* ~~~
*/
pub fn puts<T: ToStr>(input: T) {
stdout().write_line(input.to_str());
}

pub struct BytesWriter {
bytes: @mut ~[u8],
pos: @mut uint,
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub use option::{Option, Some, None};
pub use result::{Result, Ok, Err};

// Reexported functions
pub use io::{print, println};
pub use io::{print, println,puts};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be , puts with a space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I'll fix it ;)

pub use iter::range;
pub use from_str::from_str;

Expand Down