The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
};
if result.is_err() {
- println("parsing failed");
+ println!("parsing failed");
}
}
// print out all the elements in the vector
for x in xs.iter() {
- println(x.to_str())
+ println!("{}", *x)
}
// print out all but the first 3 elements in the vector
for x in xs.iter().skip(3) {
- println(x.to_str())
+ println!("{}", *x)
}
~~~
fn main() {
let a = Point { x: 10, y: 20 };
do spawn {
- println(a.x.to_str());
+ println!("{}", a.x);
}
}
~~~
fn main() {
let a = ~Point { x: 10, y: 20 };
do spawn {
- println(a.x.to_str());
+ println!("{}", a.x);
}
}
~~~
fn main() {
let a = ~Point { x: 10, y: 20 };
let b = a;
- println(b.x.to_str());
- println(a.x.to_str());
+ println!("{}", b.x);
+ println!("{}", a.x);
}
~~~
You'll get this error:
~~~ {.notrust}
-test.rs:10:12: 10:13 error: use of moved value: `a`
-test.rs:10 println(a.x.to_str());
- ^
-test.rs:8:8: 8:9 note: `a` moved here because it has type `~Point`, which is moved by default (use `ref` to override)
+test.rs:10:20: 10:21 error: use of moved value: `a`
+test.rs:10 println!("{}", a.x);
+ ^
+note: in expansion of format_args!
+<std-macros>:158:27: 158:81 note: expansion site
+<std-macros>:157:5: 159:6 note: in expansion of println!
+test.rs:10:5: 10:25 note: expansion site
+test.rs:8:9: 8:10 note: `a` moved here because it has type `~Point`, which is moved by default (use `ref` to override)
test.rs:8 let b = a;
^
~~~
fn main() {
let a = @Point { x: 10, y: 20 };
let b = a;
- println(b.x.to_str());
- println(a.x.to_str());
+ println!("{}", b.x);
+ println!("{}", a.x);
}
~~~
~~~rust{.xfail-test}
fn main() {
- println(x.to_str());
+ println!("{}", x);
let x = 5;
}
~~~
#[license = "MIT"];
pub fn world() {
- println("Hello, world.");
+ println!("Hello, world.");
}
~~~
# use std::task::spawn;
// Print something profound in a different task using a named function
-fn print_message() { println("I am running in a different task!"); }
+fn print_message() { println!("I am running in a different task!"); }
spawn(print_message);
// Print something more profound in a different task using a lambda expression
-spawn(proc() println("I am also running in a different task!") );
+spawn(proc() println!("I am also running in a different task!") );
// The canonical way to spawn is using `do` notation
do spawn {
- println("I too am running in a different task!");
+ println!("I too am running in a different task!");
}
~~~~
let mut i = 0;
while i < 10 {
- println("hello\n");
+ println!("hello");
i = i + 1;
}
~~~~
}
fn print(a: @Printable) {
- println(a.to_string());
+ println!("{}", a.to_string());
}
fn main() {
~~~~
fn main() {
- println("hello?");
+ println!("hello?");
}
~~~~
The Rust compiler tries to provide useful information when it encounters an
error. If you introduce an error into the program (for example, by changing
-`println` to some nonexistent function), and then compile it, you'll see
+`println!` to some nonexistent macro), and then compile it, you'll see
an error message like this:
~~~~ {.notrust}
-hello.rs:2:4: 2:16 error: unresolved name: print_with_unicorns
-hello.rs:2 print_with_unicorns("hello?");
+hello.rs:2:5: 2:24 error: macro undefined: 'print_with_unicorns'
+hello.rs:2 print_with_unicorns!("hello?");
^~~~~~~~~~~~~~~~~~~
~~~~
~~~~
if false {
- println("that's odd");
+ println!("that's odd");
} else if true {
- println("right");
+ println!("right");
} else {
- println("neither true nor false");
+ println!("neither true nor false");
}
~~~~
~~~~
# let my_number = 1;
match my_number {
- 0 => println("zero"),
- 1 | 2 => println("one or two"),
- 3..10 => println("three to ten"),
- _ => println("something else")
+ 0 => println!("zero"),
+ 1 | 2 => println!("one or two"),
+ 3..10 => println!("three to ten"),
+ _ => println!("something else")
}
~~~~
~~~
# let my_number = 1;
match my_number {
- 0 => { println("zero") }
- _ => { println("something else") }
+ 0 => { println!("zero") }
+ _ => { println!("something else") }
}
~~~
loop {
x += x - 3;
if x % 5 == 0 { break; }
- println(x.to_str());
+ println!("{}", x);
}
~~~~
# struct Point { x: f64, y: f64 }
# let mypoint = Point { x: 0.0, y: 0.0 };
match mypoint {
- Point { x: 0.0, y: yy } => { println(yy.to_str()); }
- Point { x: xx, y: yy } => { println(xx.to_str() + " " + yy.to_str()); }
+ Point { x: 0.0, y: yy } => println!("{}", yy),
+ Point { x: xx, y: yy } => println!("{} {}", xx, yy),
}
~~~~
# struct Point { x: f64, y: f64 }
# let mypoint = Point { x: 0.0, y: 0.0 };
match mypoint {
- Point { x, .. } => { println(x.to_str()) }
+ Point { x, .. } => println!("{}", x),
}
~~~
~~~~
# fn call_it(op: proc(v: int)) { }
call_it(proc(n) {
- println(n.to_str());
+ println!("{}", n);
});
~~~~
~~~~
# fn call_it(op: proc(v: int)) { }
do call_it() |n| {
- println(n.to_str());
+ println!("{}", n);
}
~~~~
impl Drop for TimeBomb {
fn drop(&mut self) {
for _ in range(0, self.explosivity) {
- println("blam!");
+ println!("blam!");
}
}
}
}
impl Printable for ~str {
- fn print(&self) { println(*self) }
+ fn print(&self) { println!("{}", *self) }
}
# 1.print();
impl Printable for int {}
impl Printable for ~str {
- fn print(&self) { println(*self) }
+ fn print(&self) { println!("{}", *self) }
}
impl Printable for bool {}
~~~~
// main.rs
fn main() {
- println("Hello world!");
+ println!("Hello world!");
}
~~~~
mod farm {
// This is the body of module 'farm' declared in the crate root.
- fn chicken() { println("cluck cluck"); }
- fn cow() { println("mooo"); }
+ fn chicken() { println!("cluck cluck"); }
+ fn cow() { println!("mooo"); }
mod barn {
// Body of module 'barn'
- fn hay() { println("..."); }
+ fn hay() { println!("..."); }
}
}
fn main() {
- println("Hello farm!");
+ println!("Hello farm!");
}
~~~~
~~~~ {.xfail-test}
mod farm {
- fn chicken() { println("cluck cluck"); }
+ fn chicken() { println!("cluck cluck"); }
// ...
}
fn main() {
- println("Hello chicken!");
+ println!("Hello chicken!");
::farm::chicken(); // Won't compile yet, see further down
}
~~~~
mod farm {
- pub fn chicken() { println("cluck cluck"); }
- pub fn cow() { println("mooo"); }
+ pub fn chicken() { println!("cluck cluck"); }
+ pub fn cow() { println!("mooo"); }
// ...
}
fn main() {
- println("Hello chicken!");
+ println!("Hello chicken!");
::farm::chicken(); // This compiles now
}
~~~~
mod farm; // Compiler will look for 'farm.rs' and 'farm/mod.rs'
fn main() {
- println("Hello farm!");
+ println!("Hello farm!");
::farm::cow();
}
~~~~
~~~~
// farm.rs - contains body of module 'farm' in the crate root
-pub fn chicken() { println("cluck cluck"); }
-pub fn cow() { println("mooo"); }
+pub fn chicken() { println!("cluck cluck"); }
+pub fn cow() { println!("mooo"); }
pub mod barn {
- pub fn hay() { println("..."); }
+ pub fn hay() { println!("..."); }
}
# fn main() { }
~~~~
~~~
use farm::cow;
-# mod farm { pub fn cow() { println("I'm a hidden ninja cow!") } }
+# mod farm { pub fn cow() { println!("I'm a hidden ninja cow!") } }
# fn main() { cow() }
~~~
~~~
# mod workaround {
-# pub fn some_parent_item(){ println("...") }
+# pub fn some_parent_item(){ println!("...") }
# mod foo {
use super::some_parent_item;
use self::some_child_module::some_item;
# // XXX: Allow unused import in doc test
use farm::cow;
// ...
-# mod farm { pub fn cow() { println("Hidden ninja cow is hidden.") } }
-fn cow() { println("Mooo!") }
+# mod farm { pub fn cow() { println!("Hidden ninja cow is hidden.") } }
+fn cow() { println!("Mooo!") }
fn main() {
cow() // resolves to the locally defined cow() function
~~~
use farm::cow;
mod farm {
- pub fn cow() { println("Moooooo?") }
+ pub fn cow() { println!("Moooooo?") }
}
fn main() { cow() }
use farm::barn;
mod farm {
- pub fn chicken() { println("cluck cluck"); }
- pub fn cow() { println("mooo"); }
+ pub fn chicken() { println!("cluck cluck"); }
+ pub fn cow() { println!("mooo"); }
pub mod barn {
- pub fn hay() { println("..."); }
+ pub fn hay() { println!("..."); }
}
}
fn main() {
- println("Hello farm!");
+ println!("Hello farm!");
// Can now refer to those names directly:
chicken();
~~~
// c.rs
-pub fn bar() { println("Baz!"); }
+pub fn bar() { println!("Baz!"); }
# fn main() {}
~~~
~~~
use farm::{chicken, cow};
# mod farm {
-# pub fn cow() { println("Did I already mention how hidden and ninja I am?") }
-# pub fn chicken() { println("I'm Bat-chicken, guardian of the hidden tutorial code.") }
+# pub fn cow() { println!("Did I already mention how hidden and ninja I am?") }
+# pub fn chicken() { println!("I'm Bat-chicken, guardian of the hidden tutorial code.") }
# }
# fn main() { cow(); chicken() }
~~~
~~~
use farm::*;
# mod farm {
-# pub fn cow() { println("Bat-chicken? What a stupid name!") }
-# pub fn chicken() { println("Says the 'hidden ninja' cow.") }
+# pub fn cow() { println!("Bat-chicken? What a stupid name!") }
+# pub fn chicken() { println!("Says the 'hidden ninja' cow.") }
# }
# fn main() { cow(); chicken() }
~~~
~~~
use egg_layer = farm::chicken;
-# mod farm { pub fn chicken() { println("Laying eggs is fun!") } }
+# mod farm { pub fn chicken() { println!("Laying eggs is fun!") } }
// ...
fn main() {
mod farm {
pub use self::barn::hay;
- pub fn chicken() { println("cluck cluck"); }
- pub fn cow() { println("mooo"); }
+ pub fn chicken() { println!("cluck cluck"); }
+ pub fn cow() { println!("mooo"); }
mod barn {
- pub fn hay() { println("..."); }
+ pub fn hay() { println!("..."); }
}
}
use extra::rational::Ratio;
mod farm {
- pub fn dog() { println("woof"); }
+ pub fn dog() { println!("woof"); }
}
fn main() {
~~~~ {.xfail-test}
// main.rs
extern mod world;
-fn main() { println("hello " + world::explore()); }
+fn main() { println!("hello {}", world::explore()); }
~~~~
Now compile and run like this (adjust to your platform if necessary):
## The standard library and the prelude
While reading the examples in this tutorial, you might have asked yourself where all
-those magical predefined items like `println()` are coming from.
+those magical predefined items like `range` are coming from.
The truth is, there's nothing magical about them: They are all defined normally
in the `std` library, which is a crate that ships with Rust.
The role of the `prelude` module is to re-export common definitions from `std`.
-This allows you to use common types and functions like `Option<T>` or `println`
+This allows you to use common types and functions like `Option<T>` or `range`
without needing to import them. And if you need something from `std` that's not in the prelude,
you just have to import it with an `use` statement.
-For example, it re-exports `println` which is defined in `std::io::stdio::println`:
+For example, it re-exports `range` which is defined in `std::iter::range`:
~~~
-use puts = std::io::stdio::println;
+use iter_range = std::iter::range;
fn main() {
- println("println is imported per default.");
- puts("Doesn't hinder you from importing it under a different name yourself.");
- ::std::io::stdio::println("Or from not using the automatic import.");
+ // range is imported by default
+ for _ in range(0, 10) {}
+
+ // Doesn't hinder you from importing it under a different name yourself
+ for _ in iter_range(0, 10) {}
+
+ // Or from not using the automatic import.
+ for _ in ::std::iter::range(0, 10) {}
}
~~~
let args_ = args.tail();
if args[1] == ~"-h" || args[1] == ~"--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
- println(getopts::groups::usage(message, groups));
- println("");
+ println!("{}", getopts::groups::usage(message, groups));
+ println!("");
fail!()
}
if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
- println(getopts::groups::usage(message, groups));
- println("");
+ println!("{}", getopts::groups::usage(message, groups));
+ println!("");
fail!()
}
if config.target == ~"arm-linux-androideabi" {
match config.mode{
mode_debug_info => {
- println("arm-linux-androideabi debug-info \
- test uses tcp 5039 port. please reserve it");
+ println!("arm-linux-androideabi debug-info \
+ test uses tcp 5039 port. please reserve it");
//arm-linux-androideabi debug-info test uses remote debugger
//so, we test 1 task at once
os::setenv("RUST_TEST_TASKS","1");
pub fn logv(config: &config, s: ~str) {
debug!("{}", s);
- if config.verbose { println(s); }
+ if config.verbose { println!("{}", s); }
}
//! use std::os;
//!
//! fn do_work(inp: &str, out: Option<~str>) {
-//! println(inp);
-//! println(match out {
-//! Some(x) => x,
-//! None => ~"No Output"
-//! });
+//! println!("{}", inp);
+//! match out {
+//! Some(x) => println!("{}", x),
+//! None => println!("No Output"),
+//! }
//! }
//!
//! fn print_usage(program: &str, _opts: &[Opt]) {
//! println!("Usage: {} [options]", program);
-//! println("-o\t\tOutput");
-//! println("-h --help\tUsage");
+//! println!("-o\t\tOutput");
+//! println!("-h --help\tUsage");
//! }
//!
//! fn main() {
fn usage(binary: &str, helpstr: &str) {
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
- println(groups::usage(message, optgroups()));
- println("");
+ println!("{}", groups::usage(message, optgroups()));
+ println!("");
if helpstr == "help" {
- println("\
+ println!("{}", "\
The FILTER is matched against the name of all tests to run, and if any tests
have a substring match, only those tests are run.
* use extra::url;
*
* let query = ~[(~"title", ~"The Village"), (~"north", ~"52.91"), (~"west", ~"4.10")];
- * println(url::query_to_str(&query)); // title=The%20Village&north=52.91&west=4.10
+ * println!("{}", url::query_to_str(&query)); // title=The%20Village&north=52.91&west=4.10
* ```
*/
pub fn query_to_str(query: &Query) -> ~str {
fn main() {
let uuid1 = Uuid::new_v4();
- println(uuid1.to_str());
+ println!("{}", uuid1.to_str());
}
```
}
});
- println(s);
+ println!("{}", s);
}
}
pub fn describe_warnings() {
- println("
+ println!("
Available lint options:
-W <foo> Warn about <foo>
-A <foo> Allow <foo>
fn padded(max: uint, s: &str) -> ~str {
" ".repeat(max - s.len()) + s
}
- println("\nAvailable lint checks:\n");
+ println!("{}", "\nAvailable lint checks:\n"); // FIXME: #9970
println!(" {} {:7.7s} {}",
padded(max_key, "name"), "default", "meaning");
println!(" {} {:7.7s} {}\n",
lint::level_to_str(spec.default),
spec.desc);
}
- println("");
+ println!("");
}
pub fn describe_debug_flags() {
- println("\nAvailable debug options:\n");
+ println!("{}", "\nAvailable debug options:\n"); // FIXME: #9970
let r = session::debugging_opts_map();
for tuple in r.iter() {
match *tuple {
}
};
if crate_id {
- println(crateid.to_str());
+ println!("{}", crateid.to_str());
}
if crate_name {
- println(crateid.name);
+ println!("{}", crateid.name);
}
}
}
}
- println("metadata stats:");
+ println!("metadata stats:");
println!(" inline bytes: {}", ecx.stats.inline_bytes.get());
println!(" attribute bytes: {}", ecx.stats.attr_bytes.get());
println!(" dep bytes: {}", ecx.stats.dep_bytes.get());
visit::walk_crate(bccx, crate, ());
if tcx.sess.borrowck_stats() {
- println("--- borrowck stats ---");
+ println!("--- borrowck stats ---");
println!("paths requiring guarantees: {}",
bccx.stats.guaranteed_paths.get());
println!("paths requiring loans : {}",
// Translate the metadata.
let metadata = write_metadata(ccx, &crate);
if ccx.sess.trans_stats() {
- println("--- trans stats ---");
+ println!("--- trans stats ---");
println!("n_static_tydescs: {}", ccx.stats.n_static_tydescs.get());
println!("n_glues_created: {}", ccx.stats.n_glues_created.get());
println!("n_null_glues: {}", ccx.stats.n_null_glues.get());
println!("n_monos: {}", ccx.stats.n_monos.get());
println!("n_inlines: {}", ccx.stats.n_inlines.get());
println!("n_closures: {}", ccx.stats.n_closures.get());
- println("fn stats:");
+ println!("fn stats:");
{
let mut fn_stats = ccx.stats.fn_stats.borrow_mut();
fn_stats.get().sort_by(|&(_, _, insns_a), &(_, _, insns_b)| {
}
pub fn usage(argv0: &str) {
- println(groups::usage(format!("{} [options] <input>", argv0), opts()));
+ println!("{}", groups::usage(format!("{} [options] <input>", argv0), opts()));
}
pub fn main_args(args: &[~str]) -> int {
let matches = match groups::getopts(args.tail(), opts()) {
Ok(m) => m,
Err(err) => {
- println(err.to_err_msg());
+ println!("{}", err.to_err_msg());
return 1;
}
};
}
if matches.free.len() == 0 {
- println("expected an input file to act on");
+ println!("expected an input file to act on");
return 1;
} if matches.free.len() > 1 {
- println("only one input file may be specified");
+ println!("only one input file may be specified");
return 1;
}
let input = matches.free[0].as_slice();
}
if matches.opt_strs("passes") == ~[~"list"] {
- println("Available passes for running rustdoc:");
+ println!("Available passes for running rustdoc:");
for &(name, _, description) in PASSES.iter() {
println!("{:>20s} - {}", name, description);
}
- println("\nDefault passes for rustdoc:");
+ println!("{}", "\nDefault passes for rustdoc:"); // FIXME: #9970
for &name in DEFAULT_PASSES.iter() {
println!("{:>20s}", name);
}
};
if flags.linker.is_some() && cmd != BuildCmd && cmd != InstallCmd {
- println("The --linker option can only be used with the build or install commands.");
+ println!("The --linker option can only be used with the build or install commands.");
return true;
}
if flags.link_args.is_some() && cmd != BuildCmd && cmd != InstallCmd {
- println("The --link-args option can only be used with the build or install commands.");
+ println!("The --link-args option can only be used with the build or install commands.");
return true;
}
if !cfgs.is_empty() && cmd != BuildCmd && cmd != InstallCmd && cmd != TestCmd {
- println("The --cfg option can only be used with the build, test, or install commands.");
+ println!("The --cfg option can only be used with the build, test, or install commands.");
return true;
}
if user_supplied_opt_level && cmd != BuildCmd && cmd != InstallCmd {
- println("The -O and --opt-level options can only be used with the build \
+ println!("The -O and --opt-level options can only be used with the build \
or install commands.");
return true;
}
if flags.save_temps && cmd != BuildCmd && cmd != InstallCmd {
- println("The --save-temps option can only be used with the build \
+ println!("The --save-temps option can only be used with the build \
or install commands.");
return true;
}
if flags.target.is_some() && cmd != BuildCmd && cmd != InstallCmd {
- println("The --target option can only be used with the build \
+ println!("The --target option can only be used with the build \
or install commands.");
return true;
}
if flags.target_cpu.is_some() && cmd != BuildCmd && cmd != InstallCmd {
- println("The --target-cpu option can only be used with the build \
+ println!("The --target-cpu option can only be used with the build \
or install commands.");
return true;
}
if flags.experimental_features.is_some() && cmd != BuildCmd && cmd != InstallCmd {
- println("The -Z option can only be used with the build or install commands.");
+ println!("The -Z option can only be used with the build or install commands.");
return true;
}
}
}
ListCmd => {
- println("Installed packages:");
+ println!("Installed packages:");
installed_packages::list_installed_packages(|pkg_id| {
- pkg_id.path.display().with_str(|s| println(s));
+ pkg_id.path.display().with_str(|s| println!("{}", s));
true
});
}
}
pub fn main() {
- println("WARNING: The Rust package manager is experimental and may be unstable");
+ println!("WARNING: The Rust package manager is experimental and may be unstable");
os::set_exit_status(main_args(os::args()));
}
target.as_str().unwrap().to_owned()]);
let outp = opt_outp.expect("Failed to exec `git`");
if !outp.status.success() {
- println(str::from_utf8_owned(outp.output.clone()));
- println(str::from_utf8_owned(outp.error));
+ println!("{}", str::from_utf8_owned(outp.output.clone()));
+ println!("{}", str::from_utf8_owned(outp.error));
return DirToUse(target.clone());
}
else {
format!("--git-dir={}", git_dir.as_str().unwrap().to_owned()),
~"checkout", format!("{}", *s)]).expect("Failed to exec `git`");
if !outp.status.success() {
- println(str::from_utf8_owned(outp.output.clone()));
- println(str::from_utf8_owned(outp.error));
+ println!("{}", str::from_utf8_owned(outp.output.clone()));
+ println!("{}", str::from_utf8_owned(outp.error));
return DirToUse(target.clone());
}
}
*/
fn main() {
- println(~"Hello world!");
+ println!("Hello world!");
}
}
if args[2] != ~"install" {
- println(format!("Warning: I don't know how to {}", args[2]));
+ println!("Warning: I don't know how to {}", args[2]);
return;
}
*/
fn main() {
- println("Hello world!");
+ println!("Hello world!");
}
use context::Command;
pub fn general() {
- println("Usage: rustpkg [options] <cmd> [args..]
+ println!("Usage: rustpkg [options] <cmd> [args..]
Where <cmd> is one of:
build, clean, do, info, install, list, prefer, test, uninstall, unprefer
}
pub fn build() {
- println("rustpkg build [options..] [package-ID]
+ println!("rustpkg build [options..] [package-ID]
Build the given package ID if specified. With no package ID argument,
build the package in the current directory. In that case, the current
}
pub fn clean() {
- println("rustpkg clean
+ println!("rustpkg clean
Remove all build files in the work cache for the package in the current
directory.");
}
pub fn do_cmd() {
- println("rustpkg do <cmd>
+ println!(r"rustpkg do <cmd>
Runs a command in the package script. You can listen to a command
-by tagging a function with the attribute `#[pkg_do(cmd)]`.");
+by tagging a function with the attribute `\#[pkg_do(cmd)]`.");
}
pub fn info() {
- println("rustpkg [options..] info
+ println!("rustpkg [options..] info
Probe the package script in the current directory for information.
}
pub fn list() {
- println("rustpkg list
+ println!("rustpkg list
List all installed packages.");
}
pub fn install() {
- println("rustpkg install [options..] [package-ID]
+ println!(r"rustpkg install [options..] [package-ID]
Install the given package ID if specified. With no package ID
argument, install the package in the current directory.
Examples:
rustpkg install
rustpkg install github.com/mozilla/servo
- rustpkg install github.com/mozilla/servo#0.1.2
+ rustpkg install github.com/mozilla/servo\#0.1.2
Options:
-c, --cfg Pass a cfg flag to the package script
}
pub fn uninstall() {
- println("rustpkg uninstall <id|name>[@version]
+ println!("rustpkg uninstall <id|name>[@version]
Remove a package by id or name and optionally version. If the package(s)
is/are depended on by another package then they cannot be removed.");
}
pub fn prefer() {
- println("rustpkg [options..] prefer <id|name>[@version]
+ println!("rustpkg [options..] prefer <id|name>[@version]
By default all binaries are given a unique name so that multiple versions can
coexist. The prefer command will symlink the uniquely named binary to
}
pub fn unprefer() {
- println("rustpkg [options..] unprefer <id|name>[@version]
+ println!("rustpkg [options..] unprefer <id|name>[@version]
Remove all symlinks from the store to the binary directory for a package
name and optionally version. If version is not supplied, the latest version
}
pub fn test() {
- println("rustpkg [options..] test
+ println!("rustpkg [options..] test
Build all test crates in the current directory with the test flag.
Then, run all the resulting test executables, redirecting the output
}
pub fn init() {
- println("rustpkg init
+ println!("rustpkg init
This will turn the current working directory into a workspace. The first
command you run when starting off a new project.
///
/// ```
/// std::bool::all_values(|x: bool| {
-/// println(x.to_str());
+/// println!("{}", x);
/// })
/// ```
#[inline]
// condition, then the above handler will be invoked (so long as there's no
// other nested handler).
- println(my_error::cond.raise(3)); // prints "three"
- println(my_error::cond.raise(4)); // prints "oh well"
+ println!("{}", my_error::cond.raise(3)); // prints "three"
+ println!("{}", my_error::cond.raise(4)); // prints "oh well"
})
# let _g = ::std::io::ignore_io_error();
let mut stdin = BufferedReader::new(stdin());
for line in stdin.lines() {
- print(line);
+ print!("{}", line);
}
```
let path = Path::new("message.txt");
let mut file = BufferedReader::new(File::open(&path));
for line in file.lines() {
- print(line);
+ print!("{}", line);
}
```
});
if error.is_some() {
- println("failed to write my diary");
+ println!("failed to write my diary");
}
# ::std::io::fs::unlink(&Path::new("diary.txt"));
```
/// do spawn {
/// loop {
/// match listener.port.recv() {
-/// Interrupt => println("Got Interrupt'ed"),
+/// Interrupt => println!("Got Interrupt'ed"),
/// _ => (),
/// }
/// }
/// .filter(|&x| x % 2 == 0)
/// .inspect(|&x| debug!("{} made it through", x))
/// .sum();
- /// println(sum.to_str());
+ /// println!("{}", sum);
/// ```
#[inline]
fn inspect<'r>(self, f: 'r |&A|) -> Inspect<'r, A, Self> {
* }
* }
* fn main() {
- * println(format!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3}));
- * println(format!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3}));
+ * println!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
+ * println!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
* }
* ```
*
*
* impl Drop for HasDrop {
* fn drop(&mut self) {
- * println("Dropping!");
+ * println!("Dropping!");
* }
* }
*
*
* impl Add<Foo, Foo> for Foo {
* fn add(&self, _rhs: &Foo) -> Foo {
- * println("Adding!");
+ * println!("Adding!");
* *self
* }
* }
*
* impl Sub<Foo, Foo> for Foo {
* fn sub(&self, _rhs: &Foo) -> Foo {
- * println("Subtracting!");
+ * println!("Subtracting!");
* *self
* }
* }
*
* impl Mul<Foo, Foo> for Foo {
* fn mul(&self, _rhs: &Foo) -> Foo {
- * println("Multiplying!");
+ * println!("Multiplying!");
* *self
* }
* }
*
* impl Div<Foo, Foo> for Foo {
* fn div(&self, _rhs: &Foo) -> Foo {
- * println("Dividing!");
+ * println!("Dividing!");
* *self
* }
* }
*
* impl Rem<Foo, Foo> for Foo {
* fn rem(&self, _rhs: &Foo) -> Foo {
- * println("Remainder-ing!");
+ * println!("Remainder-ing!");
* *self
* }
* }
*
* impl Neg<Foo> for Foo {
* fn neg(&self) -> Foo {
- * println("Negating!");
+ * println!("Negating!");
* *self
* }
* }
*
* impl Not<Foo> for Foo {
* fn not(&self) -> Foo {
- * println("Not-ing!");
+ * println!("Not-ing!");
* *self
* }
* }
*
* impl BitAnd<Foo, Foo> for Foo {
* fn bitand(&self, _rhs: &Foo) -> Foo {
- * println("Bitwise And-ing!");
+ * println!("Bitwise And-ing!");
* *self
* }
* }
*
* impl BitOr<Foo, Foo> for Foo {
* fn bitor(&self, _rhs: &Foo) -> Foo {
- * println("Bitwise Or-ing!");
+ * println!("Bitwise Or-ing!");
* *self
* }
* }
*
* impl BitXor<Foo, Foo> for Foo {
* fn bitxor(&self, _rhs: &Foo) -> Foo {
- * println("Bitwise Xor-ing!");
+ * println!("Bitwise Xor-ing!");
* *self
* }
* }
*
* impl Shl<Foo, Foo> for Foo {
* fn shl(&self, _rhs: &Foo) -> Foo {
- * println("Shifting left!");
+ * println!("Shifting left!");
* *self
* }
* }
*
* impl Shr<Foo, Foo> for Foo {
* fn shr(&self, _rhs: &Foo) -> Foo {
- * println("Shifting right!");
+ * println!("Shifting right!");
* *self
* }
* }
*
* impl Index<Foo, Foo> for Foo {
* fn index(&self, _rhs: &Foo) -> Foo {
- * println("Indexing!");
+ * println!("Indexing!");
* *self
* }
* }
//!
//! // Take a reference to the contained string
//! match msg {
-//! Some(ref m) => io::println(*m),
+//! Some(ref m) => println!("{}", *m),
//! None => ()
//! }
//!
// Reexported functions
pub use from_str::from_str;
pub use iter::range;
-pub use io::stdio::{print, println};
// Reexported types and traits
/// ```rust
/// use std::rand::{task_rng, Rng};
///
- /// println(task_rng().gen_ascii_str(10));
+ /// println!("{}", task_rng().gen_ascii_str(10));
/// ```
fn gen_ascii_str(&mut self, len: uint) -> ~str {
static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\
/// let mut rng = ReseedingRng::new(rand::StdRng::new(), 10, rsdr);
///
/// // this will repeat, because it gets reseeded very regularly.
-/// println(rng.gen_ascii_str(100));
+/// println!("{}", rng.gen_ascii_str(100));
/// }
///
/// ```
use prelude::*;
use str;
use str::Str;
+ use io::stdio::println;
use util::swap;
use char::is_alphabetic;
/// assert_eq!(d.len(), 23);
///
/// // the two strings *look* the same
- /// println(c);
- /// println(d);
+ /// println!("{}", c);
+ /// println!("{}", d);
/// ```
fn char_len(&self) -> uint;
/// let v = ~[~"a", ~"b"];
/// for s in v.move_iter() {
/// // s has type ~str, not &~str
- /// println(s);
+ /// println!("{}", s);
/// }
/// ```
fn move_iter(self) -> MoveIterator<T>;
// - two renames of the same var.. can only happen if you use
// local-expand to prevent the inner binding from being renamed
// during the rename-pass caused by the first:
- println("about to run bad test");
+ println!("about to run bad test");
{ let sc = unfold_test_sc(~[R(id(a,EMPTY_CTXT),50),
R(id(a,EMPTY_CTXT),51)],
EMPTY_CTXT,&mut t);
//fn expand_and_resolve(crate_str: @str) -> ast::crate {
//let expanded_ast = expand_crate_str(crate_str);
- // println(format!("expanded: {:?}\n",expanded_ast));
+ // println!("expanded: {:?}\n",expanded_ast);
//mtwt_resolve_crate(expanded_ast)
//}
//fn expand_and_resolve_and_pretty_print (crate_str : @str) -> ~str {
let varref_marks = mtwt_marksof(varref.segments[0].identifier.ctxt,
invalid_name);
if (!(varref_name==binding_name)){
- println("uh oh, should match but doesn't:");
+ println!("uh oh, should match but doesn't:");
println!("varref: {:?}",varref);
println!("binding: {:?}", bindings[binding_idx]);
ast_util::display_sctable(get_sctable());
&& (@"xx" == (ident_to_str(&p.segments[0].identifier)))
}).enumerate() {
if (mtwt_resolve(v.segments[0].identifier) != resolved_binding) {
- println("uh oh, xx binding didn't match xx varref:");
+ println!("uh oh, xx binding didn't match xx varref:");
println!("this is xx varref \\# {:?}",idx);
println!("binding: {:?}",cxbind);
println!("resolves to: {:?}",resolved_binding);
println!("resolves to: {:?}",
mtwt_resolve(v.segments[0].identifier));
let table = get_sctable();
- println("SC table:");
+ println!("SC table:");
{
let table = table.table.borrow();
-> base::MacResult {
cx.print_backtrace();
- println(
+ println!("{}",
print::pprust::tt_to_str(
&ast::TTDelim(@tt.to_owned()),
get_ident_interner()));
#[test] fn t1 () {
let Env {string_reader} =
setup(@"/* my source file */ \
- fn main() { io::println(~\"zebra\"); }\n");
+ fn main() { println!(\"zebra\"); }\n");
let id = str_to_ident("fn");
let tok1 = string_reader.next_token();
let tok2 = TokenAndSpan{
impl Foo for Bar {
#[inline(always)]
fn f(&self) {
- println((*self).x);
+ println!("{}", (*self).x);
}
}
impl Drop for S {
fn drop(&mut self) {
- println("goodbye");
+ println!("goodbye");
}
}
}
fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
- println(" Ascending integers:");
+ println!(" Ascending integers:");
timed("insert", || {
for i in range(0u, n_keys) {
}
fn descending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
- println(" Descending integers:");
+ println!(" Descending integers:");
timed("insert", || {
for i in range(0, n_keys).invert() {
println!("{} keys", n_keys);
- println("\nTreeMap:");
+ // FIXME: #9970
+ println!("{}", "\nTreeMap:");
{
let mut map: TreeMap<uint,uint> = TreeMap::new();
}
{
- println(" Random integers:");
+ println!(" Random integers:");
let mut map: TreeMap<uint,uint> = TreeMap::new();
vector(&mut map, n_keys, rand);
}
- println("\nHashMap:");
+ // FIXME: #9970
+ println!("{}", "\nHashMap:");
{
let mut map: HashMap<uint,uint> = HashMap::new();
}
{
- println(" Random integers:");
+ println!(" Random integers:");
let mut map: HashMap<uint,uint> = HashMap::new();
vector(&mut map, n_keys, rand);
}
- println("\nTrieMap:");
+ // FIXME: #9970
+ println!("{}", "\nTrieMap:");
{
let mut map: TrieMap<uint> = TrieMap::new();
}
{
- println(" Random integers:");
+ println!(" Random integers:");
let mut map: TrieMap<uint> = TrieMap::new();
vector(&mut map, n_keys, rand);
}
}
fn write_header(header: &str) {
- println(header);
+ println!("{}", header);
}
fn write_row(label: &str, value: f64) {
for y in range(0, 256) {
for x in range(0, 256) {
- print(symbols[(pixels[y*256+x] / 0.2f32) as int]);
+ print!("{}", symbols[(pixels[y*256+x] / 0.2f32) as int]);
}
- println("");
+ println!("");
}
}
}).to_owned_vec();
for message in messages.mut_iter() {
- println(*message.get_ref());
+ println!("{}", *message.get_ref());
}
println!("long lived tree of depth {}\t check: {}",
let all = [Blue, Red, Yellow];
for aa in all.iter() {
for bb in all.iter() {
- println(show_color(*aa) + " + " + show_color(*bb) +
- " -> " + show_color(transform(*aa, *bb)));
+ println!("{} + {} -> {}", show_color(*aa), show_color(*bb),
+ show_color(transform(*aa, *bb)));
}
}
}
}
// print each color in the set
- println(show_color_list(set));
+ println!("{}", show_color_list(set));
// print each creature's stats
for rep in report.iter() {
- println(*rep);
+ println!("{}", *rep);
}
// print the total number of creatures met
- println(show_number(creatures_met));
+ println!("{}", show_number(creatures_met));
}
fn main() {
let nn = from_str::<uint>(args[1]).unwrap();
print_complements();
- println("");
+ println!("");
rendezvous(nn, ~[Blue, Red, Yellow]);
- println("");
+ println!("");
rendezvous(nn,
~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]);
// Use incremental change to generate another permutation.
loop {
if r == n {
- println(checksum.to_str());
+ println!("{}", checksum);
return max_flips_count;
}
// now fetch and print result messages
for (ii, _sz) in sizes.iter().enumerate() {
- println(from_child[ii].recv());
+ println!("{}", from_child[ii].recv());
}
}
fn main() {
let args = std::os::args();
let (w, mut out) = if args.len() < 2 {
- println("Test mode: do not dump the image because it's not utf8, \
- which interferes with the test runner.");
+ println!("Test mode: do not dump the image because it's not utf8, \
+ which interferes with the test runner.");
(1000, ~DummyWriter as ~Writer)
} else {
(from_str(args[1]).unwrap(),
// Prints a solution in ~str form.
fn print_sol(sol: &str) {
for (i, c) in sol.chars().enumerate() {
- if (i) % 5 == 0 {println("");}
- if (i + 5) % 10 == 0 {print(" ");}
+ if (i) % 5 == 0 { println!(""); }
+ if (i + 5) % 10 == 0 { print!(" "); }
print!("{} ", c);
}
- println("");
+ println!("");
}
// The data managed during the search
println!("{} solutions found", data.nb);
print_sol(data.min);
print_sol(data.max);
- println("");
+ println!("");
}
let m = n % 10;
if m != 0 {
- for _ in range(m, 10) {print(" ");}
+ for _ in range(m, 10) { print!(" "); }
print!("\t:{}\n", n);
}
}
fn g() {
let mut x: Either<int,f64> = Left(3);
- println(f(&mut x, &x).to_str()); //~ ERROR cannot borrow
+ println!("{}", f(&mut x, &x)); //~ ERROR cannot borrow
}
fn h() {
struct S {f:~str}
impl Drop for S {
- fn drop(&mut self) { println(self.f); }
+ fn drop(&mut self) { println!("{}", self.f); }
}
fn move_in_match() {
},
None => { fail!() }
}
- println(*msg);
+ println!("{}", *msg);
}
};
match &s.x {
&Foo => {}
- &Bar(ref identifier) => println(*identifier)
+ &Bar(ref identifier) => println!("{}", *identifier)
};
}
mod circular_modules_main;
pub fn say_hello() {
- println(circular_modules_main::hi_str());
+ println!("{}", circular_modules_main::hi_str());
}
fn main() {
let string = "world!";
- let f: |&str| = |s| println(s + string);
+ let f: |&str| = |s| println!("{}", s + string);
call_bare(f) //~ ERROR mismatched types
}
impl Drop for Foo { //~ ERROR the Drop trait may only be implemented
//~^ ERROR cannot provide an extension implementation
fn drop(&mut self) {
- println("kaboom");
+ println!("kaboom");
}
}
impl Drop for Foo {
fn drop(&mut self) {
- println("kaboom");
+ println!("kaboom");
}
}
impl Drop for Foo {
fn drop(&mut self) {
- println("kaboom");
+ println!("kaboom");
}
}
struct A { y: Arc<int>, x: Arc<int> }
impl Drop for A {
- fn drop(&mut self) { println(format!("x={:?}", self.x.get())); }
+ fn drop(&mut self) { println!("x={:?}", self.x.get()); }
}
fn main() {
let a = A { y: Arc::new(1), x: Arc::new(2) };
}
fn main() {
- println("hello");
+ println!("hello");
let x = ~"foo";
let y = x;
- println(y);
+ println!("{}", y);
}
impl Drop for foo {
fn drop(&mut self) {
unsafe {
- println("Goodbye, World!");
+ println!("Goodbye, World!");
self.x.set(self.x.get() + 1);
}
}
fn main() {
if Lol(2) == Lol(4) {
- println("2 == 4");
+ println!("2 == 4");
} else {
- println("2 != 4");
+ println!("2 != 4");
}
}
fn main() {
let p = Point::new(0.0f, 0.0f);
- io::println(p.to_str());
+ println!("{}", p.to_str());
}
macro_rules! print_hd_tl (
($field_hd:ident, $($field_tl:ident),+) => ({
- print(stringify!($field)); //~ ERROR unknown macro variable
- print("::[");
+ print!("{}", stringify!($field)); //~ ERROR unknown macro variable
+ print!("::[");
$(
- print(stringify!($field_tl));
- print(", ");
+ print!("{}", stringify!($field_tl));
+ print!(", ");
)+
- print("]\n");
+ // FIXME: #9970
+ print!("{}", "]\n");
})
)
}
match ~[~"foo", ~"bar", ~"baz"] {
- [a, _, _, ..] => { println(a); }
+ [a, _, _, ..] => { println!("{}", a); }
[~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
_ => { }
}
f(&s, |hellothere| {
match hellothere.x {
~Foo(_) => {}
- ~Bar(x) => println(x.to_str()), //~ ERROR cannot move out
+ ~Bar(x) => println!("{}", x.to_str()), //~ ERROR cannot move out
~Baz => {}
}
})
fn main() {
let x = ~"Hello world!";
do task::spawn {
- println(x);
+ println!("{}", x);
}
- println(x); //~ ERROR use of moved value
+ println!("{}", x); //~ ERROR use of moved value
}
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn foo() {
- print("foo"); //~ ERROR: unresolved name
- println("bar"); //~ ERROR: unresolved name
+ drop(2) //~ ERROR: unresolved name
}
}
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn foo() {
- print("foo"); //~ ERROR: unresolved name
- println("bar"); //~ ERROR: unresolved name
+ drop(2) //~ ERROR: unresolved name
}
}
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn foo() {
- print("foo"); //~ ERROR: unresolved name
- println("bar"); //~ ERROR: unresolved name
+ drop(2) //~ ERROR: unresolved name
}
}
}
fn main() {
// these should work fine
- print("foo");
- println("bar");
+ drop(2)
}
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn main() {
- print("foo"); //~ ERROR: unresolved name
- println("bar"); //~ ERROR: unresolved name
+ drop(2) //~ ERROR: unresolved name
}
// except according to those terms.
fn main() {
- let f = |3: int| println("hello"); //~ ERROR refutable pattern
+ let f = |3: int| println!("hello"); //~ ERROR refutable pattern
f(4);
}
impl Drop for Foo {
fn drop(&mut self) {
- println("Goodbye!");
+ println!("Goodbye!");
}
}
enum E {}
fn f(e: E) {
- println((e as int).to_str()); //~ ERROR non-scalar cast
+ println!("{}", (e as int).to_str()); //~ ERROR non-scalar cast
}
fn main() {}
impl Foo for Bar {
fn f(&self) {
- println("hi");
+ println!("hi");
}
}
fn main() {
let x = ~"Hello!";
let _y = x;
- println(x); //~ ERROR use of moved value
+ println!("{}", x); //~ ERROR use of moved value
}
fn main() {
let x = S { x: 1 };
- println(x.foo().to_str());
+ println!("{}", x.foo());
}
fn main() {
let x = S { x: ~1 };
- println(x.foo().to_str());
+ println!("{}", x.foo());
}
}
fn function_call(x: u64, y: u64, z: f64) {
- print("Hi!")
+ std::io::stdio::print("Hi!")
}
fn identifier(x: u64, y: u64, z: f64) -> u64 {
#[no_split_stack]
fn function_call(x: u64, y: u64, z: f64) {
- print("Hi!")
+ std::io::stdio::print("Hi!")
}
#[no_split_stack]
pub fn main() {
let x = Foo::new();
- println(x.x.to_str());
+ println!("{}", x.x);
}
pub fn main() {
let x = Foo::new();
- println(x.x.to_str());
+ println!("{}", x.x);
}
impl Baz for Bar {
fn g(&self) {
- println(self.x.to_str());
+ println!("{}", self.x);
}
}
pub fn main() {
let x: &'static str = "foo";
- println(x);
+ println!("{}", x);
}
impl Foo for int {
fn foo(@self) {
- println("Hello world!");
+ println!("Hello world!");
}
}
* http://creativecommons.org/publicdomain/zero/1.0/ */
use std::cast;
+use std::io::stdio::println;
fn call_it(f: proc(~str) -> ~str) {
- println(f(~"Fred"))
+ println!("{}", f(~"Fred"))
}
fn call_a_thunk(f: ||) {
// Closures
- call_a_thunk(|| println("Hello world!"));
+ call_a_thunk(|| println!("Hello world!"));
- call_this(|s| println(s));
+ call_this(|s| println!("{}", s));
call_that(|x, y| *x + *y);
trait Foo {
fn f(&self) {
- println("Hello!");
+ println!("Hello!");
self.g();
}
fn g(&self);
impl Foo for A {
fn g(&self) {
- println("Goodbye!");
+ println!("Goodbye!");
}
}
#[unsafe_destructor]
impl<T> ::std::ops::Drop for S<T> {
fn drop(&mut self) {
- println("bye");
+ println!("bye");
}
}
impl Drop for Foo {
fn drop(&mut self) {
- println("bye");
+ println!("bye");
}
}
pub fn main() {
let v: ~[int] = ~[ 1, ..5 ];
- println(v[0].to_str());
- println(v[1].to_str());
- println(v[2].to_str());
- println(v[3].to_str());
- println(v[4].to_str());
+ println!("{}", v[0]);
+ println!("{}", v[1]);
+ println!("{}", v[2]);
+ println!("{}", v[3]);
+ println!("{}", v[4]);
let v: @[int] = @[ 2, ..5 ];
- println(v[0].to_str());
- println(v[1].to_str());
- println(v[2].to_str());
- println(v[3].to_str());
- println(v[4].to_str());
+ println!("{}", v[0]);
+ println!("{}", v[1]);
+ println!("{}", v[2]);
+ println!("{}", v[3]);
+ println!("{}", v[4]);
}
use extra::json::Object;
pub fn main() {
- println("Hello world!");
+ println!("Hello world!");
}
pub fn main() {
let x: f32 = 4.0;
- println(x.to_str());
+ println!("{}", x);
let y: f64 = 64.0;
- println(y.to_str());
+ println!("{}", y);
let z = S { z: 1.0 };
- println(z.z.to_str());
+ println!("{}", z.z);
}
pub fn main() {
let v : &[(int,int)] = &[ (1, 2), (3, 4), (5, 6) ];
for &(x, y) in v.iter() {
- println(y.to_str());
- println(x.to_str());
+ println!("{}", y);
+ println!("{}", x);
}
}
// except according to those terms.
pub fn main() {
- println("hello, world");
+ println!("hello, world");
}
pub fn main() {
let fish1 = impl_privacy_xc_2::Fish { x: 1 };
let fish2 = impl_privacy_xc_2::Fish { x: 2 };
- println(if fish1.eq(&fish2) { "yes" } else { "no " });
+ if fish1.eq(&fish2) { println!("yes") } else { println!("no") };
}
fn print_str_vector(vector: ~[~str]) {
for string in vector.iter() {
- println(*string);
+ println!("{}", *string);
}
}
element: S,
next: None
};
- println(ls.element);
+ println!("{}", ls.element);
}
}
fn to_string(t: @Text) {
- println(t.to_str());
+ println!("{}", t.to_str());
}
}
buildings::Tower { height: h } => { h }
};
- println(h.to_str());
+ println!("{}", h);
}
*/
fn print1(b: bool, s1: &str, s2: &str) {
- println(if b { s1 } else { s2 });
+ println!("{}", if b { s1 } else { s2 });
}
fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
- println(if b { s1 } else { s2 });
+ println!("{}", if b { s1 } else { s2 });
}
fn print3(b: bool, s1: &str, s2: &str) {
let mut s: &str;
if b { s = s1; } else { s = s2; }
- println(s);
+ println!("{}", s);
}
fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
let mut s: &str;
if b { s = s1; } else { s = s2; }
- println(s);
+ println!("{}", s);
}
pub fn main() {}
fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result {
let cmd = cmd_to_str(cmd);
- //io::println(cmd);
+ //println!("{}", cmd);
sb.write_str(cmd);
let res = parse_response(@sb as @io::Reader);
res
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::io::println;
+
pub fn main() {
let (port, chan) = Chan::new();
}
pub fn main() {
- println(parse_args());
+ println!("{}", parse_args());
}
macro_rules! print_hd_tl (
($field_hd:ident, $($field_tl:ident),+) => ({
- print(stringify!($field_hd));
- print("::[");
+ print!("{}", stringify!($field_hd));
+ print!("::[");
$(
- print(stringify!($field_tl));
- print(", ");
+ print!("{}", stringify!($field_tl));
+ print!(", ");
)+
- print("]\n");
+ // FIXME: #9970
+ print!("{}", "]\n");
})
)
impl Fooable for uint {
fn yes(self) {
- self.times(|| println("yes"));
+ self.times(|| println!("yes"));
}
}
}
impl Inner for int {
- fn print(&self) { print(format!("Inner: {}\n", *self)); }
+ fn print(&self) { print!("Inner: {}\n", *self); }
}
struct Outer<'a> {
pub fn main() {
let test = &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32];
- println(format!("{}",test==test1.pattern));
+ println!("{}",test==test1.pattern);
}
impl IDummy for A {
fn do_nothing(&self) {
- println("A::do_nothing() is called");
+ println!("A::do_nothing() is called");
}
}
match &[(~5,~7)] {
ps => {
let (ref y, _) = ps[0];
- println(fmt!("1. y = %d", **y));
+ println!("1. y = {}", **y);
assert!(**y == 5);
}
}
match Some(&[(~5,)]) {
Some(ps) => {
let (ref y,) = ps[0];
- println(fmt!("2. y = %d", **y));
- if **y != 5 { println("sadness"); }
+ println!("2. y = {}", **y);
+ if **y != 5 { println!("sadness"); }
}
None => ()
}
match Some(&[(~5,~7)]) {
Some(ps) => {
let (ref y, ref z) = ps[0];
- println(fmt!("3. y = %d z = %d", **y, **z));
+ println!("3. y = {} z = {}", **y, **z);
assert!(**y == 5);
}
None => ()
fn f() {
let a = ~"hello";
let b: &str = a;
- println(b);
+ println!("{}", b);
}
pub fn main() {
}
pub fn main() {
- println(parse_args());
+ println!("{}", parse_args());
}
}
pub fn bar(self) {
- println(self.x);
+ println!("{}", self.x);
}
}
pub fn main() {
let x = ~"Hello world!";
do task::spawn {
- println(x);
+ println!("{}", x);
}
}
// Test that multibyte characters don't crash the compiler
pub fn main() {
- println("마이너스 사인이 없으면");
+ println!("마이너스 사인이 없으면");
}
}
pub fn main() {
- println(Thingy { x: 1, y: 2 }.to_str());
- println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str());
+ println!("{}", Thingy { x: 1, y: 2 }.to_str());
+ println!("{}", PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str());
}
// except according to those terms.
pub fn main() {
- println("Hello world!");
+ println!("Hello world!");
}
let f = thing.find_str("{{");
if f.is_none() {
- println("None!");
+ println!("None!");
}
}
}
pub fn main() {
- let f = |(x, _): (int, int)| println((x + 1).to_str());
- let g = |Foo { x: x, y: _y }: Foo| println((x + 1).to_str());
+ let f = |(x, _): (int, int)| println!("{}", x + 1);
+ let g = |Foo { x: x, y: _y }: Foo| println!("{}", x + 1);
f((2, 3));
g(Foo { x: 1, y: 2 });
}
// pp-exact
-pub fn main() { println("Hello World"); }
+pub fn main() { println!("Hello World"); }
pub fn main() {
let act = format!("{:?}", red);
- println(act);
+ println!("{}", act);
assert_eq!(~"red", act);
assert_eq!(~"green", format!("{:?}", green));
assert_eq!(~"white", format!("{:?}", white));
#[feature(managed_boxes)];
+use std::io::println;
+
trait Trait<T> {
fn f(&self, x: T);
}
impl Trait<&'static str> for Struct {
fn f(&self, x: &'static str) {
- println(~"Hi, " + x + ~"!");
+ println!("Hi, {}!", x);
}
}
impl Trait for Struct {
fn f(&self) {
- println("Hi!");
+ println!("Hi!");
}
}
impl Foo<S> for S {
fn f(&self, x: &S) {
- println(x.x.to_str());
+ println!("{}", x.x);
}
}
impl Foo for A {
fn f(&self) -> int {
- println(~"Today's number is " + self.x.to_str());
+ println!("Today's number is {}", self.x);
return self.x;
}
}
impl ::base::HasNew<Foo> for Foo {
fn new() -> Foo {
- println("Foo");
+ println!("Foo");
Foo { dummy: () }
}
}
impl ::base::HasNew<Bar> for Bar {
fn new() -> Bar {
- println("Bar");
+ println!("Bar");
Bar { dummy: () }
}
}
pub fn main() {
let x: Foo = Foo;
match x {
- Foo => { println("hi"); }
+ Foo => { println!("hi"); }
}
}