*
* fn main () {
* let str = [52,32].to_base64(standard);
- * println(fmt!("%s", str));
+ * printfln!("%s", str);
* }
* ~~~
*/
*
* fn main () {
* let str = "Hello, World".to_base64(standard);
- * println(fmt!("%s",str));
+ * printfln!("%s", str);
* }
* ~~~
*
*
* fn main () {
* let str = [52,32].to_base64(standard);
- * println(fmt!("%s", str));
+ * printfln!("%s", str);
* let bytes = str.from_base64();
- * println(fmt!("%?",bytes));
+ * printfln!("%?", bytes);
* }
* ~~~
*/
*
* fn main () {
* let hello_str = "Hello, World".to_base64(standard);
- * println(fmt!("%s",hello_str));
+ * printfln!("%s", hello_str);
* let bytes = hello_str.from_base64();
- * println(fmt!("%?",bytes));
+ * printfln!("%?", bytes);
* let result_str = str::from_bytes(bytes);
- * println(fmt!("%s",result_str));
+ * printfln!("%s", result_str);
* }
* ~~~
*/
* # fn make_a_sandwich() {};
* let mut delayed_fib = extra::future::spawn (|| fib(5000) );
* make_a_sandwich();
- * println(fmt!("fib(5000) = %?", delayed_fib.get()))
+ * printfln!("fib(5000) = %?", delayed_fib.get())
* ~~~
*/
* }
*
* fn print_usage(program: &str, _opts: &[Opt]) {
- * println(fmt!("Usage: %s [options]", program));
+ * printfln!("Usage: %s [options]", program);
* println("-o\t\tOutput");
* println("-h --help\tUsage");
* }
};
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
for 8.times {
- pool.execute(|i| println(fmt!("Hello from thread %u!", *i)));
+ pool.execute(|i| printfln!("Hello from thread %u!", *i));
}
}
let mut n = 0;
for m.iter().advance |x| {
- println(fmt!("%?", x));
+ printfln!(x);
assert_eq!(*x, n);
n += 1
}
match find_cmd(command_string) {
Some(command) => {
match command.action {
- CallMain(prog, _) => io::println(fmt!(
+ CallMain(prog, _) => printfln!(
"The %s command is an alias for the %s program.",
- command.cmd, prog)),
+ command.cmd, prog),
_ => ()
}
match command.usage_full {
- UsgStr(msg) => io::println(fmt!("%s\n", msg)),
+ UsgStr(msg) => printfln!("%s\n", msg),
UsgCall(f) => f(),
}
Valid(0)
for COMMANDS.iter().advance |command| {
let padding = " ".repeat(INDENT - command.cmd.len());
- io::println(fmt!(" %s%s%s",
- command.cmd, padding, command.usage_line));
+ printfln!(" %s%s%s", command.cmd, padding, command.usage_line);
}
io::print(
io::println("\nAnalysis Passes:");
for analysis_passes.iter().advance |&(name, desc)| {
- io::println(fmt!(" %-30s -- %s", name, desc));
+ printfln!(" %-30s -- %s", name, desc);
}
io::println("\nTransformation Passes:");
for transform_passes.iter().advance |&(name, desc)| {
- io::println(fmt!(" %-30s -- %s", name, desc));
+ printfln!(" %-30s -- %s", name, desc);
}
io::println("\nUtility Passes:");
for utility_passes.iter().advance |&(name, desc)| {
- io::println(fmt!(" %-30s -- %s", name, desc));
+ printfln!(" %-30s -- %s", name, desc);
}
}
if failed.len() > 0 {
io::println("Some passes don't exist:");
for failed.iter().advance |&n| {
- io::println(fmt!(" %s", n));
+ printfln!(" %s", n);
}
fail!();
}
}
io::println("metadata stats:");
- io::println(fmt!(" inline bytes: %u", ecx.stats.inline_bytes));
- io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes));
- io::println(fmt!(" dep bytes: %u", ecx.stats.dep_bytes));
- io::println(fmt!(" lang item bytes: %u", ecx.stats.lang_item_bytes));
- io::println(fmt!(" link args bytes: %u", ecx.stats.link_args_bytes));
- io::println(fmt!(" misc bytes: %u", ecx.stats.misc_bytes));
- io::println(fmt!(" item bytes: %u", ecx.stats.item_bytes));
- io::println(fmt!(" index bytes: %u", ecx.stats.index_bytes));
- io::println(fmt!(" zero bytes: %u", ecx.stats.zero_bytes));
- io::println(fmt!(" total bytes: %u", ecx.stats.total_bytes));
+ printfln!(" inline bytes: %u", ecx.stats.inline_bytes);
+ printfln!(" attribute bytes: %u", ecx.stats.attr_bytes);
+ printfln!(" dep bytes: %u", ecx.stats.dep_bytes);
+ printfln!(" lang item bytes: %u", ecx.stats.lang_item_bytes);
+ printfln!(" link args bytes: %u", ecx.stats.link_args_bytes);
+ printfln!(" misc bytes: %u", ecx.stats.misc_bytes);
+ printfln!(" item bytes: %u", ecx.stats.item_bytes);
+ printfln!(" index bytes: %u", ecx.stats.index_bytes);
+ printfln!(" zero bytes: %u", ecx.stats.zero_bytes);
+ printfln!(" total bytes: %u", ecx.stats.total_bytes);
}
// Pad this, since something (LLVM, presumably) is cutting off the
if tcx.sess.borrowck_stats() {
io::println("--- borrowck stats ---");
- io::println(fmt!("paths requiring guarantees: %u",
- bccx.stats.guaranteed_paths));
- io::println(fmt!("paths requiring loans : %s",
- make_stat(bccx, bccx.stats.loaned_paths_same)));
- io::println(fmt!("paths requiring imm loans : %s",
- make_stat(bccx, bccx.stats.loaned_paths_imm)));
- io::println(fmt!("stable paths : %s",
- make_stat(bccx, bccx.stats.stable_paths)));
- io::println(fmt!("paths requiring purity : %s",
- make_stat(bccx, bccx.stats.req_pure_paths)));
+ printfln!("paths requiring guarantees: %u",
+ bccx.stats.guaranteed_paths);
+ printfln!("paths requiring loans : %s",
+ make_stat(bccx, bccx.stats.loaned_paths_same));
+ printfln!("paths requiring imm loans : %s",
+ make_stat(bccx, bccx.stats.loaned_paths_imm));
+ printfln!("stable paths : %s",
+ make_stat(bccx, bccx.stats.stable_paths));
+ printfln!("paths requiring purity : %s",
+ make_stat(bccx, bccx.stats.req_pure_paths));
}
return (bccx.root_map, bccx.write_guard_map);
write_metadata(ccx, crate);
if ccx.sess.trans_stats() {
io::println("--- trans stats ---");
- io::println(fmt!("n_static_tydescs: %u",
- ccx.stats.n_static_tydescs));
- io::println(fmt!("n_glues_created: %u",
- ccx.stats.n_glues_created));
- io::println(fmt!("n_null_glues: %u", ccx.stats.n_null_glues));
- io::println(fmt!("n_real_glues: %u", ccx.stats.n_real_glues));
-
- io::println(fmt!("n_fns: %u", ccx.stats.n_fns));
- io::println(fmt!("n_monos: %u", ccx.stats.n_monos));
- io::println(fmt!("n_inlines: %u", ccx.stats.n_inlines));
- io::println(fmt!("n_closures: %u", ccx.stats.n_closures));
+ printfln!("n_static_tydescs: %u", ccx.stats.n_static_tydescs);
+ printfln!("n_glues_created: %u", ccx.stats.n_glues_created);
+ printfln!("n_null_glues: %u", ccx.stats.n_null_glues);
+ printfln!("n_real_glues: %u", ccx.stats.n_real_glues);
+
+ printfln!("n_fns: %u", ccx.stats.n_fns);
+ printfln!("n_monos: %u", ccx.stats.n_monos);
+ printfln!("n_inlines: %u", ccx.stats.n_inlines);
+ printfln!("n_closures: %u", ccx.stats.n_closures);
io::println("fn stats:");
do sort::quick_sort(ccx.stats.fn_stats) |&(_, _, insns_a), &(_, _, insns_b)| {
insns_a > insns_b
for ccx.stats.fn_stats.iter().advance |tuple| {
match *tuple {
(ref name, ms, insns) => {
- io::println(fmt!("%u insns, %u ms, %s", insns, ms, *name));
+ printfln!("%u insns, %u ms, %s", insns, ms, *name);
}
}
}
}
if ccx.sess.count_llvm_insns() {
for ccx.stats.llvm_insns.iter().advance |(k, v)| {
- io::println(fmt!("%-7u %s", *v, *k));
+ printfln!("%-7u %s", *v, *k);
}
}
// Uncomment this to debug calls.
/*
- io::println(fmt!("calling: %s", bcx.val_to_str(llfn)));
+ printfln!("calling: %s", bcx.val_to_str(llfn));
for llargs.iter().advance |llarg| {
- io::println(fmt!("arg: %s", bcx.val_to_str(*llarg)));
+ printfln!("arg: %s", bcx.val_to_str(*llarg));
}
io::println("---");
*/
use middle::trans::type_::Type;
-use std::io;
use std::libc::c_uint;
use std::str;
use syntax::ast;
let llty = type_of(ccx, t);
if ccx.sess.count_type_sizes() {
- io::println(fmt!("%u\t%s", llsize_of_real(ccx, llty),
- ppaux::ty_to_str(ccx.tcx, t)));
+ printfln!("%u\t%s", llsize_of_real(ccx, llty),
+ ppaux::ty_to_str(ccx.tcx, t));
}
let llsize = llsize_of(ccx, llty);
}
pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
- //io::println(fmt!("%?/%?", id, cx.node_types.len()));
+ //printfln!("%?/%?", id, cx.node_types.len());
match cx.node_types.find(&(id as uint)) {
Some(&t) => t,
None => cx.sess.bug(
let mut vers = ~"unknown version";
let env_vers = env!("CFG_VERSION");
if env_vers.len() != 0 { vers = env_vers.to_owned(); }
- io::println(fmt!("%s %s", argv0, vers));
- io::println(fmt!("host: %s", host_triple()));
+ printfln!("%s %s", argv0, vers);
+ printfln!("host: %s", host_triple());
}
pub fn usage(argv0: &str) {
let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0);
- io::println(fmt!("%s\
+ printfln!("%s\
Additional help:
-W help Print 'lint' options and default settings
-Z help Print internal options for debugging rustc\n",
- groups::usage(message, optgroups())));
+ groups::usage(message, optgroups()));
}
pub fn describe_warnings() {
use extra::sort::Sort;
- io::println(fmt!("
+ printfln!("
Available lint options:
-W <foo> Warn about <foo>
-A <foo> Allow <foo>
-D <foo> Deny <foo>
-F <foo> Forbid <foo> (deny, and deny all overrides)
-"));
+");
let lint_dict = lint::get_lint_dict();
let mut lint_dict = lint_dict.consume()
fn padded(max: uint, s: &str) -> ~str {
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
}
- io::println(fmt!("\nAvailable lint checks:\n"));
- io::println(fmt!(" %s %7.7s %s",
- padded(max_key, "name"), "default", "meaning"));
- io::println(fmt!(" %s %7.7s %s\n",
- padded(max_key, "----"), "-------", "-------"));
+ printfln!("\nAvailable lint checks:\n");
+ printfln!(" %s %7.7s %s",
+ padded(max_key, "name"), "default", "meaning");
+ printfln!(" %s %7.7s %s\n",
+ padded(max_key, "----"), "-------", "-------");
for lint_dict.consume_iter().advance |(spec, name)| {
let name = name.replace("_", "-");
- io::println(fmt!(" %s %7.7s %s",
- padded(max_key, name),
- lint::level_to_str(spec.default),
- spec.desc));
+ printfln!(" %s %7.7s %s",
+ padded(max_key, name),
+ lint::level_to_str(spec.default),
+ spec.desc);
}
io::println("");
}
pub fn describe_debug_flags() {
- io::println(fmt!("\nAvailable debug options:\n"));
+ printfln!("\nAvailable debug options:\n");
let r = session::debugging_opts_map();
for r.iter().advance |tuple| {
match *tuple {
(ref name, ref desc, _) => {
- io::println(fmt!(" -Z %-20s -- %s", *name, *desc));
+ printfln!(" -Z %-20s -- %s", *name, *desc);
}
}
}
use syntax::visit;
use std::hashmap::HashSet;
-use std::io;
use extra;
pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
let start = extra::time::precise_time_s();
let rv = thunk();
let end = extra::time::precise_time_s();
- io::println(fmt!("time: %3.3f s\t%s", end - start, what));
+ printfln!("time: %3.3f s\t%s", end - start, what);
rv
}
println("Options:\n");
let r = opts();
for r.iter().advance |opt| {
- println(fmt!(" %s", opt.second()));
+ printfln!(" %s", opt.second());
}
println("");
}
extern mod rustc;
extern mod syntax;
-use std::io;
use std::os;
use config::Config;
let config = match config::parse_config(args) {
Ok(config) => config,
Err(err) => {
- io::println(fmt!("error: %s", err));
+ printfln!("error: %s", err);
return;
}
};
None => { },
}
if (should_compile) {
- println(fmt!("compiling %s...", src_filename));
+ printfln!("compiling %s...", src_filename);
driver::compile_upto(sess, cfg, &input, driver::cu_everything,
Some(outputs));
true
if loaded_crates.is_empty() {
println("no crates loaded");
} else {
- println(fmt!("crates loaded: %s",
- loaded_crates.connect(", ")));
+ printfln!("crates loaded: %s", loaded_crates.connect(", "));
}
}
~"{" => {
}
if args[2] != ~"install" {
- io::println(fmt!("Warning: I don't know how to %s", args[2]));
+ printfln!("Warning: I don't know how to %s", args[2]);
return;
}
/// use std::iterator::Counter;
///
/// for Counter::new(0, 10).advance |i| {
- /// io::println(fmt!("%d", i));
+ /// printfln!("%d", i);
/// }
/// ~~~
fn advance(&mut self, f: &fn(A) -> bool) -> bool;
/// let nums = [1,2,3,4,5,6,7];
///
/// for uint::range_step(0, nums.len() - 1, 2) |i| {
-/// println(fmt!("%d & %d", nums[i], nums[i+1]));
+/// printfln!("%d & %d", nums[i], nums[i+1]);
/// }
/// ~~~
///
fn main() {
let mut rng = rand::rng();
if rng.gen() { // bool
- println(fmt!("int: %d, uint: %u", rng.gen(), rng.gen()))
+ printfln!("int: %d, uint: %u", rng.gen(), rng.gen())
}
}
~~~
fn main () {
let tuple_ptr = rand::random::<~(f64, char)>();
- println(fmt!("%?", tuple_ptr))
+ printfln!(tuple_ptr)
}
~~~
*/
*
* fn main() {
* let mut rng = rand::rng();
- * println(fmt!("%b",rng.gen_weighted_bool(3)));
+ * printfln!("%b", rng.gen_weighted_bool(3));
* }
* ~~~
*/
*
* fn main() {
* let mut rng = rand::rng();
- * println(fmt!("%?",rng.gen_bytes(8)));
+ * printfln!(rng.gen_bytes(8));
* }
* ~~~
*/
*
* fn main() {
* let mut rng = rand::rng();
- * println(fmt!("%d",rng.choose([1,2,4,8,16,32])));
+ * printfln!("%d", rng.choose([1,2,4,8,16,32]));
* }
* ~~~
*/
* let x = [rand::Weighted {weight: 4, item: 'a'},
* rand::Weighted {weight: 2, item: 'b'},
* rand::Weighted {weight: 2, item: 'c'}];
- * println(fmt!("%c",rng.choose_weighted(x)));
+ * printfln!("%c", rng.choose_weighted(x));
* }
* ~~~
*/
* let x = [rand::Weighted {weight: 4, item: 'a'},
* rand::Weighted {weight: 2, item: 'b'},
* rand::Weighted {weight: 2, item: 'c'}];
- * println(fmt!("%?",rng.choose_weighted_option(x)));
+ * printfln!(rng.choose_weighted_option(x));
* }
* ~~~
*/
* let x = [rand::Weighted {weight: 4, item: 'a'},
* rand::Weighted {weight: 2, item: 'b'},
* rand::Weighted {weight: 2, item: 'c'}];
- * println(fmt!("%?",rng.weighted_vec(x)));
+ * printfln!(rng.weighted_vec(x));
* }
* ~~~
*/
*
* fn main() {
* let mut rng = rand::rng();
- * println(fmt!("%?",rng.shuffle([1,2,3])));
+ * printfln!(rng.shuffle([1,2,3]));
* }
* ~~~
*/
* let mut rng = rand::rng();
* let mut y = [1,2,3];
* rng.shuffle_mut(y);
- * println(fmt!("%?",y));
+ * printfln!(y);
* rng.shuffle_mut(y);
- * println(fmt!("%?",y));
+ * printfln!(y);
* }
* ~~~
*/
///
/// fn main() {
/// let normal = 2.0 + (*rand::random::<StandardNormal>()) * 3.0;
-/// println(fmt!("%f is from a N(2, 9) distribution", normal))
+/// printfln!("%f is from a N(2, 9) distribution", normal)
/// }
/// ~~~
pub struct StandardNormal(f64);
///
/// fn main() {
/// let exp2 = (*rand::random::<Exp1>()) * 0.5;
-/// println(fmt!("%f is from a Exp(2) distribution", exp2));
+/// printfln!("%f is from a Exp(2) distribution", exp2);
/// }
/// ~~~
pub struct Exp1(f64);
* let i = 0u;
* while i < s.len() {
* let CharRange {ch, next} = s.char_range_at(i);
- * std::io::println(fmt!("%u: %c",i,ch));
+ * printfln!("%u: %c", i, ch);
* i = next;
* }
* ~~~
* ~~~ {.rust}
* let v = &[1,2,3,4];
* for v.window_iter().advance |win| {
- * io::println(fmt!("%?", win));
+ * printfln!(win);
* }
* ~~~
*
* ~~~ {.rust}
* let v = &[1,2,3,4,5];
* for v.chunk_iter().advance |win| {
- * io::println(fmt!("%?", win));
+ * printfln!(win);
* }
* ~~~
*
use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt};
use print;
-use std::io;
-
pub fn add_new_extension(cx: @ExtCtxt,
sp: span,
name: ident,
-> MacResult {
if cx.trace_macros() {
- io::println(fmt!("%s! { %s }",
- cx.str_of(name),
- print::pprust::tt_to_str(
- &ast::tt_delim(@mut arg.to_owned()),
- get_ident_interner())));
+ printfln!("%s! { %s }",
+ cx.str_of(name),
+ print::pprust::tt_to_str(
+ &ast::tt_delim(@mut arg.to_owned()),
+ get_ident_interner()));
}
// Which arm's failure should we report? (the one furthest along)
use std::io;
#[test] fn t1() {
let a = fresh_name("ghi");
- io::println(fmt!("interned name: %u,\ntextual name: %s\n",
- a,interner_get(a)));
+ printfln!("interned name: %u,\ntextual name: %s\n",
+ a, interner_get(a));
}
}