mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-04 14:07:36 +00:00
auto merge of #9550 : alexcrichton/rust/remove-printf, r=thestinger
The 0.8 release was cut, down with printf!
This commit is contained in:
commit
10e7f12daf
@ -68,7 +68,7 @@ impl<'self> ToBase64 for &'self [u8] {
|
|||||||
*
|
*
|
||||||
* fn main () {
|
* fn main () {
|
||||||
* let str = [52,32].to_base64(standard);
|
* let str = [52,32].to_base64(standard);
|
||||||
* printfln!("%s", str);
|
* println!("{}", str);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@ -177,11 +177,11 @@ impl<'self> FromBase64 for &'self str {
|
|||||||
*
|
*
|
||||||
* fn main () {
|
* fn main () {
|
||||||
* let hello_str = "Hello, World".to_base64(standard);
|
* let hello_str = "Hello, World".to_base64(standard);
|
||||||
* printfln!("%s", hello_str);
|
* println!("{}", hello_str);
|
||||||
* let bytes = hello_str.from_base64();
|
* let bytes = hello_str.from_base64();
|
||||||
* printfln!("%?", bytes);
|
* println!("{:?}", bytes);
|
||||||
* let result_str = str::from_utf8(bytes);
|
* let result_str = str::from_utf8(bytes);
|
||||||
* printfln!("%s", result_str);
|
* println!("{}", result_str);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* # fn make_a_sandwich() {};
|
* # fn make_a_sandwich() {};
|
||||||
* let mut delayed_fib = extra::future::spawn (|| fib(5000) );
|
* let mut delayed_fib = extra::future::spawn (|| fib(5000) );
|
||||||
* make_a_sandwich();
|
* make_a_sandwich();
|
||||||
* printfln!("fib(5000) = %?", delayed_fib.get())
|
* println!("fib(5000) = {}", delayed_fib.get())
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn print_usage(program: &str, _opts: &[Opt]) {
|
//! fn print_usage(program: &str, _opts: &[Opt]) {
|
||||||
//! printfln!("Usage: %s [options]", program);
|
//! println!("Usage: {} [options]", program);
|
||||||
//! println("-o\t\tOutput");
|
//! println("-o\t\tOutput");
|
||||||
//! println("-h --help\tUsage");
|
//! println("-h --help\tUsage");
|
||||||
//! }
|
//! }
|
||||||
|
@ -33,7 +33,7 @@ impl<'self> ToHex for &'self [u8] {
|
|||||||
*
|
*
|
||||||
* fn main () {
|
* fn main () {
|
||||||
* let str = [52,32].to_hex();
|
* let str = [52,32].to_hex();
|
||||||
* printfln!("%s", str);
|
* println!("{}", str);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@ -77,11 +77,11 @@ impl<'self> FromHex for &'self str {
|
|||||||
*
|
*
|
||||||
* fn main () {
|
* fn main () {
|
||||||
* let hello_str = "Hello, World".to_hex();
|
* let hello_str = "Hello, World".to_hex();
|
||||||
* printfln!("%s", hello_str);
|
* println!("{}", hello_str);
|
||||||
* let bytes = hello_str.from_hex().unwrap();
|
* let bytes = hello_str.from_hex().unwrap();
|
||||||
* printfln!("%?", bytes);
|
* println!("{:?}", bytes);
|
||||||
* let result_str = str::from_utf8(bytes);
|
* let result_str = str::from_utf8(bytes);
|
||||||
* printfln!("%s", result_str);
|
* println!("{}", result_str);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
@ -103,6 +103,6 @@ fn test_task_pool() {
|
|||||||
};
|
};
|
||||||
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
|
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
|
||||||
do 8.times {
|
do 8.times {
|
||||||
pool.execute(|i| printfln!("Hello from thread %u!", *i));
|
pool.execute(|i| println!("Hello from thread {}!", *i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,13 +136,13 @@ fn cmd_help(args: &[~str]) -> ValidUsage {
|
|||||||
match find_cmd(command_string) {
|
match find_cmd(command_string) {
|
||||||
Some(command) => {
|
Some(command) => {
|
||||||
match command.action {
|
match command.action {
|
||||||
CallMain(prog, _) => printfln!(
|
CallMain(prog, _) => println!(
|
||||||
"The %s command is an alias for the %s program.",
|
"The {} command is an alias for the {} program.",
|
||||||
command.cmd, prog),
|
command.cmd, prog),
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
match command.usage_full {
|
match command.usage_full {
|
||||||
UsgStr(msg) => printfln!("%s\n", msg),
|
UsgStr(msg) => println!("{}\n", msg),
|
||||||
UsgCall(f) => f(),
|
UsgCall(f) => f(),
|
||||||
}
|
}
|
||||||
Valid(0)
|
Valid(0)
|
||||||
@ -215,7 +215,7 @@ fn usage() {
|
|||||||
|
|
||||||
for command in COMMANDS.iter() {
|
for command in COMMANDS.iter() {
|
||||||
let padding = " ".repeat(INDENT - command.cmd.len());
|
let padding = " ".repeat(INDENT - command.cmd.len());
|
||||||
printfln!(" %s%s%s", command.cmd, padding, command.usage_line);
|
println!(" {}{}{}", command.cmd, padding, command.usage_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
io::print(
|
io::print(
|
||||||
|
@ -1822,17 +1822,17 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
io::println("metadata stats:");
|
io::println("metadata stats:");
|
||||||
printfln!(" inline bytes: %u", ecx.stats.inline_bytes);
|
println!(" inline bytes: {}", ecx.stats.inline_bytes);
|
||||||
printfln!(" attribute bytes: %u", ecx.stats.attr_bytes);
|
println!(" attribute bytes: {}", ecx.stats.attr_bytes);
|
||||||
printfln!(" dep bytes: %u", ecx.stats.dep_bytes);
|
println!(" dep bytes: {}", ecx.stats.dep_bytes);
|
||||||
printfln!(" lang item bytes: %u", ecx.stats.lang_item_bytes);
|
println!(" lang item bytes: {}", ecx.stats.lang_item_bytes);
|
||||||
printfln!(" link args bytes: %u", ecx.stats.link_args_bytes);
|
println!(" link args bytes: {}", ecx.stats.link_args_bytes);
|
||||||
printfln!(" impl bytes: %u", ecx.stats.impl_bytes);
|
println!(" impl bytes: {}", ecx.stats.impl_bytes);
|
||||||
printfln!(" misc bytes: %u", ecx.stats.misc_bytes);
|
println!(" misc bytes: {}", ecx.stats.misc_bytes);
|
||||||
printfln!(" item bytes: %u", ecx.stats.item_bytes);
|
println!(" item bytes: {}", ecx.stats.item_bytes);
|
||||||
printfln!(" index bytes: %u", ecx.stats.index_bytes);
|
println!(" index bytes: {}", ecx.stats.index_bytes);
|
||||||
printfln!(" zero bytes: %u", ecx.stats.zero_bytes);
|
println!(" zero bytes: {}", ecx.stats.zero_bytes);
|
||||||
printfln!(" total bytes: %u", ecx.stats.total_bytes);
|
println!(" total bytes: {}", ecx.stats.total_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pad this, since something (LLVM, presumably) is cutting off the
|
// Pad this, since something (LLVM, presumably) is cutting off the
|
||||||
|
@ -100,16 +100,16 @@ pub fn check_crate(
|
|||||||
|
|
||||||
if tcx.sess.borrowck_stats() {
|
if tcx.sess.borrowck_stats() {
|
||||||
io::println("--- borrowck stats ---");
|
io::println("--- borrowck stats ---");
|
||||||
printfln!("paths requiring guarantees: %u",
|
println!("paths requiring guarantees: {}",
|
||||||
bccx.stats.guaranteed_paths);
|
bccx.stats.guaranteed_paths);
|
||||||
printfln!("paths requiring loans : %s",
|
println!("paths requiring loans : {}",
|
||||||
make_stat(bccx, bccx.stats.loaned_paths_same));
|
make_stat(bccx, bccx.stats.loaned_paths_same));
|
||||||
printfln!("paths requiring imm loans : %s",
|
println!("paths requiring imm loans : {}",
|
||||||
make_stat(bccx, bccx.stats.loaned_paths_imm));
|
make_stat(bccx, bccx.stats.loaned_paths_imm));
|
||||||
printfln!("stable paths : %s",
|
println!("stable paths : {}",
|
||||||
make_stat(bccx, bccx.stats.stable_paths));
|
make_stat(bccx, bccx.stats.stable_paths));
|
||||||
printfln!("paths requiring purity : %s",
|
println!("paths requiring purity : {}",
|
||||||
make_stat(bccx, bccx.stats.req_pure_paths));
|
make_stat(bccx, bccx.stats.req_pure_paths));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bccx.root_map, bccx.write_guard_map);
|
return (bccx.root_map, bccx.write_guard_map);
|
||||||
|
@ -121,7 +121,7 @@ impl Drop for _InsnCtxt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
|
pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
|
||||||
debug!("new InsnCtxt: %s", s);
|
debug2!("new InsnCtxt: {}", s);
|
||||||
do local_data::modify(task_local_insn_key) |c| {
|
do local_data::modify(task_local_insn_key) |c| {
|
||||||
do c.map_move |ctx| {
|
do c.map_move |ctx| {
|
||||||
let mut ctx = (*ctx).clone();
|
let mut ctx = (*ctx).clone();
|
||||||
@ -3147,15 +3147,15 @@ pub fn trans_crate(sess: session::Session,
|
|||||||
write_metadata(ccx, crate);
|
write_metadata(ccx, crate);
|
||||||
if ccx.sess.trans_stats() {
|
if ccx.sess.trans_stats() {
|
||||||
io::println("--- trans stats ---");
|
io::println("--- trans stats ---");
|
||||||
printfln!("n_static_tydescs: %u", ccx.stats.n_static_tydescs);
|
println!("n_static_tydescs: {}", ccx.stats.n_static_tydescs);
|
||||||
printfln!("n_glues_created: %u", ccx.stats.n_glues_created);
|
println!("n_glues_created: {}", ccx.stats.n_glues_created);
|
||||||
printfln!("n_null_glues: %u", ccx.stats.n_null_glues);
|
println!("n_null_glues: {}", ccx.stats.n_null_glues);
|
||||||
printfln!("n_real_glues: %u", ccx.stats.n_real_glues);
|
println!("n_real_glues: {}", ccx.stats.n_real_glues);
|
||||||
|
|
||||||
printfln!("n_fns: %u", ccx.stats.n_fns);
|
println!("n_fns: {}", ccx.stats.n_fns);
|
||||||
printfln!("n_monos: %u", ccx.stats.n_monos);
|
println!("n_monos: {}", ccx.stats.n_monos);
|
||||||
printfln!("n_inlines: %u", ccx.stats.n_inlines);
|
println!("n_inlines: {}", ccx.stats.n_inlines);
|
||||||
printfln!("n_closures: %u", ccx.stats.n_closures);
|
println!("n_closures: {}", ccx.stats.n_closures);
|
||||||
io::println("fn stats:");
|
io::println("fn stats:");
|
||||||
do sort::quick_sort(ccx.stats.fn_stats) |&(_, _, insns_a), &(_, _, insns_b)| {
|
do sort::quick_sort(ccx.stats.fn_stats) |&(_, _, insns_a), &(_, _, insns_b)| {
|
||||||
insns_a > insns_b
|
insns_a > insns_b
|
||||||
@ -3163,14 +3163,14 @@ pub fn trans_crate(sess: session::Session,
|
|||||||
for tuple in ccx.stats.fn_stats.iter() {
|
for tuple in ccx.stats.fn_stats.iter() {
|
||||||
match *tuple {
|
match *tuple {
|
||||||
(ref name, ms, insns) => {
|
(ref name, ms, insns) => {
|
||||||
printfln!("%u insns, %u ms, %s", insns, ms, *name);
|
println!("{} insns, {} ms, {}", insns, ms, *name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ccx.sess.count_llvm_insns() {
|
if ccx.sess.count_llvm_insns() {
|
||||||
for (k, v) in ccx.stats.llvm_insns.iter() {
|
for (k, v) in ccx.stats.llvm_insns.iter() {
|
||||||
printfln!("%-7u %s", *v, *k);
|
println!("{:7u} {}", *v, *k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,8 +646,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
|
|||||||
let llty = type_of(ccx, t);
|
let llty = type_of(ccx, t);
|
||||||
|
|
||||||
if ccx.sess.count_type_sizes() {
|
if ccx.sess.count_type_sizes() {
|
||||||
printfln!("%u\t%s", llsize_of_real(ccx, llty),
|
println!("{}\t{}", llsize_of_real(ccx, llty),
|
||||||
ppaux::ty_to_str(ccx.tcx, t));
|
ppaux::ty_to_str(ccx.tcx, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
let has_header = match ty::get(t).sty {
|
let has_header = match ty::get(t).sty {
|
||||||
|
@ -130,13 +130,13 @@ pub fn version(argv0: &str) {
|
|||||||
Some(vers) => vers,
|
Some(vers) => vers,
|
||||||
None => "unknown version"
|
None => "unknown version"
|
||||||
};
|
};
|
||||||
printfln!("%s %s", argv0, vers);
|
println!("{} {}", argv0, vers);
|
||||||
printfln!("host: %s", host_triple());
|
println!("host: {}", host_triple());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn usage(argv0: &str) {
|
pub fn usage(argv0: &str) {
|
||||||
let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0);
|
let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0);
|
||||||
printfln!("%s\n\
|
println!("{}\n\
|
||||||
Additional help:
|
Additional help:
|
||||||
-W help Print 'lint' options and default settings
|
-W help Print 'lint' options and default settings
|
||||||
-Z help Print internal options for debugging rustc\n",
|
-Z help Print internal options for debugging rustc\n",
|
||||||
@ -167,16 +167,16 @@ Available lint options:
|
|||||||
str::from_utf8(vec::from_elem(max - s.len(), ' ' as u8)) + s
|
str::from_utf8(vec::from_elem(max - s.len(), ' ' as u8)) + s
|
||||||
}
|
}
|
||||||
println("\nAvailable lint checks:\n");
|
println("\nAvailable lint checks:\n");
|
||||||
printfln!(" %s %7.7s %s",
|
println!(" {} {:7.7s} {}",
|
||||||
padded(max_key, "name"), "default", "meaning");
|
padded(max_key, "name"), "default", "meaning");
|
||||||
printfln!(" %s %7.7s %s\n",
|
println!(" {} {:7.7s} {}\n",
|
||||||
padded(max_key, "----"), "-------", "-------");
|
padded(max_key, "----"), "-------", "-------");
|
||||||
for (spec, name) in lint_dict.move_iter() {
|
for (spec, name) in lint_dict.move_iter() {
|
||||||
let name = name.replace("_", "-");
|
let name = name.replace("_", "-");
|
||||||
printfln!(" %s %7.7s %s",
|
println!(" {} {:7.7s} {}",
|
||||||
padded(max_key, name),
|
padded(max_key, name),
|
||||||
lint::level_to_str(spec.default),
|
lint::level_to_str(spec.default),
|
||||||
spec.desc);
|
spec.desc);
|
||||||
}
|
}
|
||||||
io::println("");
|
io::println("");
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ pub fn describe_debug_flags() {
|
|||||||
for tuple in r.iter() {
|
for tuple in r.iter() {
|
||||||
match *tuple {
|
match *tuple {
|
||||||
(ref name, ref desc, _) => {
|
(ref name, ref desc, _) => {
|
||||||
printfln!(" -Z %-20s -- %s", *name, *desc);
|
println!(" -Z {:>20s} -- {}", *name, *desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
|
|||||||
let start = extra::time::precise_time_s();
|
let start = extra::time::precise_time_s();
|
||||||
let rv = thunk();
|
let rv = thunk();
|
||||||
let end = extra::time::precise_time_s();
|
let end = extra::time::precise_time_s();
|
||||||
printfln!("time: %3.3f s\t%s", end - start, what);
|
println!("time: {:3.3f} s\t{}", end - start, what);
|
||||||
rv
|
rv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
|
|||||||
if loaded_crates.is_empty() {
|
if loaded_crates.is_empty() {
|
||||||
println("no crates loaded");
|
println("no crates loaded");
|
||||||
} else {
|
} else {
|
||||||
printfln!("crates loaded: %s", loaded_crates.connect(", "));
|
println!("crates loaded: {}", loaded_crates.connect(", "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~"{" => {
|
~"{" => {
|
||||||
|
@ -34,7 +34,7 @@ pub fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if args[2] != ~"install" {
|
if args[2] != ~"install" {
|
||||||
printfln!("Warning: I don't know how to %s", args[2]);
|
println!("Warning: I don't know how to {}", args[2]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ pub trait Iterator<A> {
|
|||||||
/// use std::iter::count;
|
/// use std::iter::count;
|
||||||
///
|
///
|
||||||
/// for i in count(0, 10) {
|
/// for i in count(0, 10) {
|
||||||
/// printfln!("%d", i);
|
/// println!("{}", i);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -70,7 +70,7 @@ fn ziggurat<R:Rng>(rng: &mut R,
|
|||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let normal = 2.0 + (*rand::random::<StandardNormal>()) * 3.0;
|
/// let normal = 2.0 + (*rand::random::<StandardNormal>()) * 3.0;
|
||||||
/// printfln!("%f is from a N(2, 9) distribution", normal)
|
/// println!("{} is from a N(2, 9) distribution", normal)
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct StandardNormal(f64);
|
pub struct StandardNormal(f64);
|
||||||
@ -124,7 +124,7 @@ impl Rand for StandardNormal {
|
|||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let exp2 = (*rand::random::<Exp1>()) * 0.5;
|
/// let exp2 = (*rand::random::<Exp1>()) * 0.5;
|
||||||
/// printfln!("%f is from a Exp(2) distribution", exp2);
|
/// println!("{} is from a Exp(2) distribution", exp2);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Exp1(f64);
|
pub struct Exp1(f64);
|
||||||
|
@ -28,7 +28,7 @@ use std::rand::Rng;
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut rng = rand::rng();
|
let mut rng = rand::rng();
|
||||||
if rng.gen() { // bool
|
if rng.gen() { // bool
|
||||||
printfln!("int: %d, uint: %u", rng.gen(), rng.gen())
|
println!("int: {}, uint: {}", rng.gen::<int>(), rng.gen::<uint>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -38,7 +38,7 @@ use std::rand;
|
|||||||
|
|
||||||
fn main () {
|
fn main () {
|
||||||
let tuple_ptr = rand::random::<~(f64, char)>();
|
let tuple_ptr = rand::random::<~(f64, char)>();
|
||||||
printfln!(tuple_ptr)
|
println!(tuple_ptr)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
@ -270,8 +270,8 @@ pub trait Rng {
|
|||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let rng = rand::task_rng();
|
/// let rng = rand::task_rng();
|
||||||
/// let x: uint = rng.gen();
|
/// let x: uint = rng.gen();
|
||||||
/// printfln!(x);
|
/// println!("{}", x);
|
||||||
/// printfln!(rng.gen::<(float, bool)>());
|
/// println!("{:?}", rng.gen::<(float, bool)>());
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@ -289,8 +289,8 @@ pub trait Rng {
|
|||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let rng = rand::task_rng();
|
/// let rng = rand::task_rng();
|
||||||
/// let x: ~[uint] = rng.gen_vec(10);
|
/// let x: ~[uint] = rng.gen_vec(10);
|
||||||
/// printfln!(x);
|
/// println!("{:?}", x);
|
||||||
/// printfln!(rng.gen_vec::<(float, bool)>(5));
|
/// println!("{:?}", rng.gen_vec::<(float, bool)>(5));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn gen_vec<T: Rand>(&mut self, len: uint) -> ~[T] {
|
fn gen_vec<T: Rand>(&mut self, len: uint) -> ~[T] {
|
||||||
@ -314,9 +314,9 @@ pub trait Rng {
|
|||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let rng = rand::task_rng();
|
/// let rng = rand::task_rng();
|
||||||
/// let n: uint = rng.gen_integer_range(0u, 10);
|
/// let n: uint = rng.gen_integer_range(0u, 10);
|
||||||
/// printfln!(n);
|
/// println!("{}", n);
|
||||||
/// let m: i16 = rng.gen_integer_range(-40, 400);
|
/// let m: i16 = rng.gen_integer_range(-40, 400);
|
||||||
/// printfln!(m);
|
/// println!("{}", m);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn gen_integer_range<T: Rand + Int>(&mut self, low: T, high: T) -> T {
|
fn gen_integer_range<T: Rand + Int>(&mut self, low: T, high: T) -> T {
|
||||||
@ -341,7 +341,7 @@ pub trait Rng {
|
|||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let mut rng = rand::rng();
|
/// let mut rng = rand::rng();
|
||||||
/// printfln!("%b", rng.gen_weighted_bool(3));
|
/// println!("{:b}", rng.gen_weighted_bool(3));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn gen_weighted_bool(&mut self, n: uint) -> bool {
|
fn gen_weighted_bool(&mut self, n: uint) -> bool {
|
||||||
@ -385,8 +385,8 @@ pub trait Rng {
|
|||||||
/// use std::rand;
|
/// use std::rand;
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// printfln!(rand::task_rng().choose_option([1,2,4,8,16,32]));
|
/// println!("{:?}", rand::task_rng().choose_option([1,2,4,8,16,32]));
|
||||||
/// printfln!(rand::task_rng().choose_option([]));
|
/// println!("{:?}", rand::task_rng().choose_option([]));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
|
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
|
||||||
@ -411,7 +411,7 @@ pub trait Rng {
|
|||||||
/// let x = [rand::Weighted {weight: 4, item: 'a'},
|
/// let x = [rand::Weighted {weight: 4, item: 'a'},
|
||||||
/// rand::Weighted {weight: 2, item: 'b'},
|
/// rand::Weighted {weight: 2, item: 'b'},
|
||||||
/// rand::Weighted {weight: 2, item: 'c'}];
|
/// rand::Weighted {weight: 2, item: 'c'}];
|
||||||
/// printfln!("%c", rng.choose_weighted(x));
|
/// println!("{}", rng.choose_weighted(x));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn choose_weighted<T:Clone>(&mut self, v: &[Weighted<T>]) -> T {
|
fn choose_weighted<T:Clone>(&mut self, v: &[Weighted<T>]) -> T {
|
||||||
@ -432,7 +432,7 @@ pub trait Rng {
|
|||||||
/// let x = [rand::Weighted {weight: 4, item: 'a'},
|
/// let x = [rand::Weighted {weight: 4, item: 'a'},
|
||||||
/// rand::Weighted {weight: 2, item: 'b'},
|
/// rand::Weighted {weight: 2, item: 'b'},
|
||||||
/// rand::Weighted {weight: 2, item: 'c'}];
|
/// rand::Weighted {weight: 2, item: 'c'}];
|
||||||
/// printfln!(rng.choose_weighted_option(x));
|
/// println!("{:?}", rng.choose_weighted_option(x));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn choose_weighted_option<T:Clone>(&mut self, v: &[Weighted<T>])
|
fn choose_weighted_option<T:Clone>(&mut self, v: &[Weighted<T>])
|
||||||
@ -469,7 +469,7 @@ pub trait Rng {
|
|||||||
/// let x = [rand::Weighted {weight: 4, item: 'a'},
|
/// let x = [rand::Weighted {weight: 4, item: 'a'},
|
||||||
/// rand::Weighted {weight: 2, item: 'b'},
|
/// rand::Weighted {weight: 2, item: 'b'},
|
||||||
/// rand::Weighted {weight: 2, item: 'c'}];
|
/// rand::Weighted {weight: 2, item: 'c'}];
|
||||||
/// printfln!(rng.weighted_vec(x));
|
/// println!("{}", rng.weighted_vec(x));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn weighted_vec<T:Clone>(&mut self, v: &[Weighted<T>]) -> ~[T] {
|
fn weighted_vec<T:Clone>(&mut self, v: &[Weighted<T>]) -> ~[T] {
|
||||||
@ -490,7 +490,7 @@ pub trait Rng {
|
|||||||
/// use std::rand;
|
/// use std::rand;
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// printfln!(rand::task_rng().shuffle(~[1,2,3]));
|
/// println!("{:?}", rand::task_rng().shuffle(~[1,2,3]));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn shuffle<T>(&mut self, values: ~[T]) -> ~[T] {
|
fn shuffle<T>(&mut self, values: ~[T]) -> ~[T] {
|
||||||
@ -510,9 +510,9 @@ pub trait Rng {
|
|||||||
/// let rng = rand::task_rng();
|
/// let rng = rand::task_rng();
|
||||||
/// let mut y = [1,2,3];
|
/// let mut y = [1,2,3];
|
||||||
/// rng.shuffle_mut(y);
|
/// rng.shuffle_mut(y);
|
||||||
/// printfln!(y);
|
/// println!("{:?}", y);
|
||||||
/// rng.shuffle_mut(y);
|
/// rng.shuffle_mut(y);
|
||||||
/// printfln!(y);
|
/// println!("{:?}", y);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn shuffle_mut<T>(&mut self, values: &mut [T]) {
|
fn shuffle_mut<T>(&mut self, values: &mut [T]) {
|
||||||
@ -535,7 +535,7 @@ pub trait Rng {
|
|||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let rng = rand::task_rng();
|
/// let rng = rand::task_rng();
|
||||||
/// let sample = rng.sample(range(1, 100), 5);
|
/// let sample = rng.sample(range(1, 100), 5);
|
||||||
/// printfln!(sample);
|
/// println!("{:?}", sample);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn sample<A, T: Iterator<A>>(&mut self, iter: T, n: uint) -> ~[A] {
|
fn sample<A, T: Iterator<A>>(&mut self, iter: T, n: uint) -> ~[A] {
|
||||||
|
@ -1695,7 +1695,7 @@ pub trait StrSlice<'self> {
|
|||||||
/// let i = 0u;
|
/// let i = 0u;
|
||||||
/// while i < s.len() {
|
/// while i < s.len() {
|
||||||
/// let CharRange {ch, next} = s.char_range_at(i);
|
/// let CharRange {ch, next} = s.char_range_at(i);
|
||||||
/// printfln!("%u: %c", i, ch);
|
/// println!("{}: {}", i, ch);
|
||||||
/// i = next;
|
/// i = next;
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1003,7 +1003,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
|
|||||||
* ```rust
|
* ```rust
|
||||||
* let v = &[1,2,3,4];
|
* let v = &[1,2,3,4];
|
||||||
* for win in v.window_iter() {
|
* for win in v.window_iter() {
|
||||||
* printfln!(win);
|
* println!("{:?}", win);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
@ -1032,7 +1032,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
|
|||||||
* ```rust
|
* ```rust
|
||||||
* let v = &[1,2,3,4,5];
|
* let v = &[1,2,3,4,5];
|
||||||
* for win in v.chunk_iter() {
|
* for win in v.chunk_iter() {
|
||||||
* printfln!(win);
|
* println!("{:?}", win);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
@ -1012,26 +1012,6 @@ pub fn std_macros() -> @str {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE(acrichto): start removing this after the next snapshot
|
|
||||||
macro_rules! printf (
|
|
||||||
($arg:expr) => (
|
|
||||||
print(fmt!(\"%?\", $arg))
|
|
||||||
);
|
|
||||||
($( $arg:expr ),+) => (
|
|
||||||
print(fmt!($($arg),+))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// NOTE(acrichto): start removing this after the next snapshot
|
|
||||||
macro_rules! printfln (
|
|
||||||
($arg:expr) => (
|
|
||||||
println(fmt!(\"%?\", $arg))
|
|
||||||
);
|
|
||||||
($( $arg:expr ),+) => (
|
|
||||||
println(fmt!($($arg),+))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
macro_rules! format(($($arg:tt)*) => (
|
macro_rules! format(($($arg:tt)*) => (
|
||||||
format_args!(::std::fmt::format, $($arg)*)
|
format_args!(::std::fmt::format, $($arg)*)
|
||||||
))
|
))
|
||||||
|
@ -66,7 +66,7 @@ fn generic_extension(cx: @ExtCtxt,
|
|||||||
rhses: &[@named_match])
|
rhses: &[@named_match])
|
||||||
-> MacResult {
|
-> MacResult {
|
||||||
if cx.trace_macros() {
|
if cx.trace_macros() {
|
||||||
printfln!("%s! { %s }",
|
println!("{}! \\{ {} \\}",
|
||||||
cx.str_of(name),
|
cx.str_of(name),
|
||||||
print::pprust::tt_to_str(
|
print::pprust::tt_to_str(
|
||||||
&ast::tt_delim(@mut arg.to_owned()),
|
&ast::tt_delim(@mut arg.to_owned()),
|
||||||
@ -194,7 +194,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
|
|||||||
rhses: &[@named_match])
|
rhses: &[@named_match])
|
||||||
-> MacResult {
|
-> MacResult {
|
||||||
if cx.trace_macros() {
|
if cx.trace_macros() {
|
||||||
printfln!("%s! { %s }",
|
println!("{}! \\{ {} \\}",
|
||||||
cx.str_of(name),
|
cx.str_of(name),
|
||||||
print::pprust::tt_to_str(
|
print::pprust::tt_to_str(
|
||||||
&ast::tt_delim(@mut arg.to_owned()),
|
&ast::tt_delim(@mut arg.to_owned()),
|
||||||
|
@ -24,7 +24,7 @@ fn timed(label: &str, f: &fn()) {
|
|||||||
let start = time::precise_time_s();
|
let start = time::precise_time_s();
|
||||||
f();
|
f();
|
||||||
let end = time::precise_time_s();
|
let end = time::precise_time_s();
|
||||||
printfln!(" %s: %f", label, end - start);
|
println!(" {}: {}", label, end - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
|
fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
|
||||||
@ -116,7 +116,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printfln!("%? keys", n_keys);
|
println!("{} keys", n_keys);
|
||||||
|
|
||||||
io::println("\nTreeMap:");
|
io::println("\nTreeMap:");
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) {
|
|||||||
test();
|
test();
|
||||||
let stop = precise_time_s();
|
let stop = precise_time_s();
|
||||||
|
|
||||||
printfln!("%s:\t\t%f ms", name, (stop - start) * 1000f);
|
println!("{}:\t\t{} ms", name, (stop - start) * 1000f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shift_push() {
|
fn shift_push() {
|
||||||
|
@ -118,7 +118,7 @@ fn main() {
|
|||||||
let elapsed = (stop - start);
|
let elapsed = (stop - start);
|
||||||
let rate = (num_msgs as float) / elapsed;
|
let rate = (num_msgs as float) / elapsed;
|
||||||
|
|
||||||
printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
|
println!("Sent {} messages in {} seconds", num_msgs, elapsed);
|
||||||
printfln!(" %? messages / second", rate);
|
println!(" {} messages / second", rate);
|
||||||
printfln!(" %? μs / message", 1000000. / rate);
|
println!(" {} μs / message", 1000000. / rate);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ fn main() {
|
|||||||
let elapsed = (stop - start);
|
let elapsed = (stop - start);
|
||||||
let rate = (num_msgs as float) / elapsed;
|
let rate = (num_msgs as float) / elapsed;
|
||||||
|
|
||||||
printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
|
println!("Sent {} messages in {} seconds", num_msgs, elapsed);
|
||||||
printfln!(" %? messages / second", rate);
|
println!(" {} messages / second", rate);
|
||||||
printfln!(" %? μs / message", 1000000. / rate);
|
println!(" {} μs / message", 1000000. / rate);
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,5 @@ fn main() {
|
|||||||
args
|
args
|
||||||
};
|
};
|
||||||
let n = from_str::<int>(args[1]).unwrap();
|
let n = from_str::<int>(args[1]).unwrap();
|
||||||
printfln!("Ack(3,%d): %d\n", n, ack(3, n));
|
println!("Ack(3,{}): {}\n", n, ack(3, n));
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ fn main() {
|
|||||||
let stretch_depth = max_depth + 1;
|
let stretch_depth = max_depth + 1;
|
||||||
let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth);
|
let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth);
|
||||||
|
|
||||||
printfln!("stretch tree of depth %d\t check: %d",
|
println!("stretch tree of depth {}\t check: {}",
|
||||||
stretch_depth,
|
stretch_depth,
|
||||||
item_check(stretch_tree));
|
item_check(stretch_tree));
|
||||||
|
|
||||||
@ -79,11 +79,11 @@ fn main() {
|
|||||||
chk += item_check(temp_tree);
|
chk += item_check(temp_tree);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
printfln!("%d\t trees of depth %d\t check: %d",
|
println!("{}\t trees of depth {}\t check: {}",
|
||||||
iterations * 2, depth, chk);
|
iterations * 2, depth, chk);
|
||||||
depth += 2;
|
depth += 2;
|
||||||
}
|
}
|
||||||
printfln!("long lived tree of depth %d\t check: %d",
|
println!("long lived tree of depth {}\t check: {}",
|
||||||
max_depth,
|
max_depth,
|
||||||
item_check(long_lived_tree));
|
item_check(long_lived_tree));
|
||||||
}
|
}
|
||||||
|
@ -94,5 +94,5 @@ fn fannkuch_redux(n: i32) -> i32 {
|
|||||||
#[fixed_stack_segment]
|
#[fixed_stack_segment]
|
||||||
fn main() {
|
fn main() {
|
||||||
let n: i32 = FromStr::from_str(os::args()[1]).unwrap();
|
let n: i32 = FromStr::from_str(os::args()[1]).unwrap();
|
||||||
printfln!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int);
|
println!("Pfannkuchen({}) = {}", n as int, fannkuch_redux(n) as int);
|
||||||
}
|
}
|
||||||
|
@ -31,5 +31,5 @@ fn main() {
|
|||||||
args
|
args
|
||||||
};
|
};
|
||||||
let n = from_str::<int>(args[1]).unwrap();
|
let n = from_str::<int>(args[1]).unwrap();
|
||||||
printfln!("%d\n", fib(n));
|
println!("{}\n", fib(n));
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ struct PrintCallback(&'static str);
|
|||||||
|
|
||||||
impl TableCallback for PrintCallback {
|
impl TableCallback for PrintCallback {
|
||||||
fn f(&self, entry: &mut Entry) {
|
fn f(&self, entry: &mut Entry) {
|
||||||
printfln!("%d\t%s", entry.count as int, **self);
|
println!("{}\t{}", entry.count as int, **self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,9 +279,9 @@ fn print_frequencies(frequencies: &Table, frame: i32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for vector.each |&(key, count)| {
|
for vector.each |&(key, count)| {
|
||||||
printfln!("%s %.3f",
|
println!("{} {:.3f}",
|
||||||
key.unpack(frame),
|
key.unpack(frame),
|
||||||
(count as float * 100.0) / (total_count as float));
|
(count as float * 100.0) / (total_count as float));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ fn main() {
|
|||||||
let mut byte_acc: i8 = 0;
|
let mut byte_acc: i8 = 0;
|
||||||
let mut bit_num: i32 = 0;
|
let mut bit_num: i32 = 0;
|
||||||
|
|
||||||
printfln!("P4\n%d %d", w as int, h as int);
|
println!("P4\n{} {}", w, h);
|
||||||
|
|
||||||
let mode = "w";
|
let mode = "w";
|
||||||
let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));
|
let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));
|
||||||
|
@ -143,9 +143,9 @@ fn main() {
|
|||||||
let mut bodies = BODIES;
|
let mut bodies = BODIES;
|
||||||
|
|
||||||
offset_momentum(&mut bodies);
|
offset_momentum(&mut bodies);
|
||||||
printfln!("%.9f", energy(&bodies) as float);
|
println!("{:.9f}", energy(&bodies) as float);
|
||||||
|
|
||||||
advance(&mut bodies, 0.01, n);
|
advance(&mut bodies, 0.01, n);
|
||||||
|
|
||||||
printfln!("%.9f", energy(&bodies) as float);
|
println!("{:.9f}", energy(&bodies) as float);
|
||||||
}
|
}
|
||||||
|
@ -63,5 +63,5 @@ fn main() {
|
|||||||
mult_AtAv(v, u, tmp);
|
mult_AtAv(v, u, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
printfln!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float);
|
println!("{:.9f}", (dot(u,v) / dot(v,v)).sqrt() as float);
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,11 @@ fn roundtrip(id: int, n_tasks: int, p: &Port<int>, ch: &Chan<int>) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
match p.recv() {
|
match p.recv() {
|
||||||
1 => {
|
1 => {
|
||||||
printfln!("%d\n", id);
|
println!("{}\n", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
token => {
|
token => {
|
||||||
info!("thread: %d got token: %d", id, token);
|
info2!("thread: {} got token: {}", id, token);
|
||||||
ch.send(token - 1);
|
ch.send(token - 1);
|
||||||
if token <= n_tasks {
|
if token <= n_tasks {
|
||||||
return;
|
return;
|
||||||
|
@ -18,7 +18,7 @@ struct Foo {
|
|||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
pub fn printme(&mut self) {
|
pub fn printme(&mut self) {
|
||||||
printfln!("%d", self.x);
|
println!("{}", self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,5 +9,5 @@ fn a() -> &int {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let fifth = a();
|
let fifth = a();
|
||||||
printfln!("%d", *fifth);
|
println!("{}", *fifth);
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,4 @@ fn main() {
|
|||||||
let u = Thing {x: 2};
|
let u = Thing {x: 2};
|
||||||
let _v = u.mul(&3); // This is ok
|
let _v = u.mul(&3); // This is ok
|
||||||
let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing`
|
let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing`
|
||||||
printfln!("%i", w.x);
|
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,5 @@ fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cann
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let v = &5;
|
let v = &5;
|
||||||
printfln!("%d", f(v)());
|
println!("{}", f(v)());
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ fn innocent_looking_victim() {
|
|||||||
match x {
|
match x {
|
||||||
Some(ref msg) => {
|
Some(ref msg) => {
|
||||||
(f.c)(f, true);
|
(f.c)(f, true);
|
||||||
printfln!(msg);
|
println!("{:?}", msg);
|
||||||
},
|
},
|
||||||
None => fail!("oops"),
|
None => fail!("oops"),
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ struct Foo(int, int);
|
|||||||
fn main() {
|
fn main() {
|
||||||
let x = Foo(1, 2);
|
let x = Foo(1, 2);
|
||||||
match x { //~ ERROR non-exhaustive
|
match x { //~ ERROR non-exhaustive
|
||||||
Foo(1, b) => printfln!("%d", b),
|
Foo(1, b) => println!("{}", b),
|
||||||
Foo(2, b) => printfln!("%d", b)
|
Foo(2, b) => println!("{}", b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,5 +33,5 @@ pub fn main()
|
|||||||
let z = @mut [1,2,3];
|
let z = @mut [1,2,3];
|
||||||
let z2 = z;
|
let z2 = z;
|
||||||
add(z.my_mut_slice(), z2.my_slice());
|
add(z.my_mut_slice(), z2.my_slice());
|
||||||
printfln!("%d", z[0]);
|
println!("{}", z[0]);
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@ pub fn main()
|
|||||||
let z = @mut [1,2,3];
|
let z = @mut [1,2,3];
|
||||||
let z2 = z;
|
let z2 = z;
|
||||||
add(z, z2);
|
add(z, z2);
|
||||||
printfln!("%d", z[0]);
|
println!("{}", z[0]);
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ pub fn main()
|
|||||||
let z = @mut [1,2,3];
|
let z = @mut [1,2,3];
|
||||||
let z2 = z;
|
let z2 = z;
|
||||||
add(&mut z[0], &z2[0]);
|
add(&mut z[0], &z2[0]);
|
||||||
printfln!("%d", z[0]);
|
println!("{}", z[0]);
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ pub fn main()
|
|||||||
let z = @mut [1,2,3];
|
let z = @mut [1,2,3];
|
||||||
let z2 = z;
|
let z2 = z;
|
||||||
add(&mut z[0], &mut z2[0]);
|
add(&mut z[0], &mut z2[0]);
|
||||||
printfln!("%d", z[0]);
|
println!("{}", z[0]);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ trait Stuff {
|
|||||||
|
|
||||||
impl Stuff for Foo {
|
impl Stuff for Foo {
|
||||||
fn printme(&self) {
|
fn printme(&self) {
|
||||||
printfln!("%d", self.x);
|
println!("{}", self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,5 +10,5 @@ pub fn main()
|
|||||||
let z = @mut [1,2,3];
|
let z = @mut [1,2,3];
|
||||||
let z2 = z;
|
let z2 = z;
|
||||||
add(&z[0], &z2[0]);
|
add(&z[0], &z2[0]);
|
||||||
printfln!("%d", z[0]);
|
println!("{}", z[0]);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ pub fn main() {
|
|||||||
//info!("%?", bt0);
|
//info!("%?", bt0);
|
||||||
|
|
||||||
do 3u.to(10u) |i| {
|
do 3u.to(10u) |i| {
|
||||||
printfln!("%u", i);
|
println!("{}", i);
|
||||||
|
|
||||||
//let bt1 = sys::frame_address();
|
//let bt1 = sys::frame_address();
|
||||||
//info!("%?", bt1);
|
//info!("%?", bt1);
|
||||||
|
@ -17,7 +17,7 @@ pub fn main() {
|
|||||||
//let bt0 = sys::rusti::frame_address(1u32);
|
//let bt0 = sys::rusti::frame_address(1u32);
|
||||||
//info!("%?", bt0);
|
//info!("%?", bt0);
|
||||||
do cci_iter_lib::iter([1, 2, 3]) |i| {
|
do cci_iter_lib::iter([1, 2, 3]) |i| {
|
||||||
printf!("%d", *i);
|
println!("{}", *i);
|
||||||
//assert!(bt0 == sys::rusti::frame_address(2u32));
|
//assert!(bt0 == sys::rusti::frame_address(2u32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ pub fn main() {
|
|||||||
//let bt0 = sys::frame_address();
|
//let bt0 = sys::frame_address();
|
||||||
//info!("%?", bt0);
|
//info!("%?", bt0);
|
||||||
do iter(~[1u, 2u, 3u]) |i| {
|
do iter(~[1u, 2u, 3u]) |i| {
|
||||||
printfln!("%u", i);
|
println!("{}", i);
|
||||||
|
|
||||||
//let bt1 = sys::frame_address();
|
//let bt1 = sys::frame_address();
|
||||||
//info!("%?", bt1);
|
//info!("%?", bt1);
|
||||||
|
@ -25,9 +25,9 @@ static k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
|
|||||||
static m : int = k.c.e;
|
static m : int = k.c.e;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
printfln!(p);
|
println!("{:?}", p);
|
||||||
printfln!(q);
|
println!("{:?}", q);
|
||||||
printfln!(t);
|
println!("{:?}", t);
|
||||||
assert_eq!(p, 3);
|
assert_eq!(p, 3);
|
||||||
assert_eq!(q, 3);
|
assert_eq!(q, 3);
|
||||||
assert_eq!(t, 20);
|
assert_eq!(t, 20);
|
||||||
|
@ -21,5 +21,5 @@ static y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0,
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let (p, _) = y.x;
|
let (p, _) = y.x;
|
||||||
assert_eq!(p, - 1085102592571150096);
|
assert_eq!(p, - 1085102592571150096);
|
||||||
printfln!("0x%x", p as uint);
|
println!("{:#x}", p);
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ static x: &'static int = &10;
|
|||||||
static y: &'static Pair<'static> = &Pair {a: 15, b: x};
|
static y: &'static Pair<'static> = &Pair {a: 15, b: x};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
printfln!("x = %?", *x);
|
println!("x = {}", *x);
|
||||||
printfln!("y = {a: %?, b: %?}", y.a, *(y.b));
|
println!("y = \\{a: {}, b: {}\\}", y.a, *(y.b));
|
||||||
assert_eq!(*x, 10);
|
assert_eq!(*x, 10);
|
||||||
assert_eq!(*(y.b), 10);
|
assert_eq!(*(y.b), 10);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,6 @@ pub fn main() {
|
|||||||
assert_eq!(z.b, 22);
|
assert_eq!(z.b, 22);
|
||||||
assert_eq!(w.a, 5);
|
assert_eq!(w.a, 5);
|
||||||
assert_eq!(w.c, 3);
|
assert_eq!(w.c, 3);
|
||||||
printfln!("0x%x", x.b as uint);
|
println!("{:#x}", x.b);
|
||||||
printfln!("0x%x", z.c as uint);
|
println!("{:#x}", z.c);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ static x : [int, ..4] = [1,2,3,4];
|
|||||||
static y : &'static [int] = &[1,2,3,4];
|
static y : &'static [int] = &[1,2,3,4];
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
printfln!(x[1]);
|
println!("{:?}", x[1]);
|
||||||
printfln!(y[1]);
|
println!("{:?}", y[1]);
|
||||||
assert_eq!(x[1], 2);
|
assert_eq!(x[1], 2);
|
||||||
assert_eq!(x[3], 4);
|
assert_eq!(x[3], 4);
|
||||||
assert_eq!(x[3], y[3]);
|
assert_eq!(x[3], y[3]);
|
||||||
|
@ -16,5 +16,5 @@ struct Foo {
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let a = Foo { x: 1, y: 2 };
|
let a = Foo { x: 1, y: 2 };
|
||||||
let c = Foo { x: 4, .. a};
|
let c = Foo { x: 4, .. a};
|
||||||
printfln!(c);
|
println!("{:?}", c);
|
||||||
}
|
}
|
||||||
|
@ -82,5 +82,5 @@ pub fn main() {
|
|||||||
a);
|
a);
|
||||||
let sum = foldl(filt, 0u, |accum, &&n: uint| accum + n );
|
let sum = foldl(filt, 0u, |accum, &&n: uint| accum + n );
|
||||||
|
|
||||||
printfln!("%u", sum);
|
println!("{}", sum);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ pub fn main() {
|
|||||||
let bools2 = to_bools(Storage{storage: ~[0b01100100]});
|
let bools2 = to_bools(Storage{storage: ~[0b01100100]});
|
||||||
|
|
||||||
for i in range(0u, 8) {
|
for i in range(0u, 8) {
|
||||||
printfln!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint);
|
println!("{} => {} vs {}", i, bools[i], bools2[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(bools, bools2);
|
assert_eq!(bools, bools2);
|
||||||
|
@ -4,5 +4,5 @@ pub fn main() {
|
|||||||
x += 1;
|
x += 1;
|
||||||
}
|
}
|
||||||
assert_eq!(x, 4096);
|
assert_eq!(x, 4096);
|
||||||
printfln!("x = %u", x);
|
println!("x = {}", x);
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,11 @@ pub fn main() {
|
|||||||
|
|
||||||
// the following compiles and works properly
|
// the following compiles and works properly
|
||||||
let v1: Vec2 = a * 3f;
|
let v1: Vec2 = a * 3f;
|
||||||
printfln!("%f %f", v1.x, v1.y);
|
println!("{} {}", v1.x, v1.y);
|
||||||
|
|
||||||
// the following compiles but v2 will not be Vec2 yet and
|
// the following compiles but v2 will not be Vec2 yet and
|
||||||
// using it later will cause an error that the type of v2
|
// using it later will cause an error that the type of v2
|
||||||
// must be known
|
// must be known
|
||||||
let v2 = a * 3f;
|
let v2 = a * 3f;
|
||||||
printfln!("%f %f", v2.x, v2.y); // error regarding v2's type
|
println!("{} {}", v2.x, v2.y); // error regarding v2's type
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,5 @@ impl Shape {
|
|||||||
|
|
||||||
pub fn main(){
|
pub fn main(){
|
||||||
let s = Circle(Point { x: 1f, y: 2f }, 3f);
|
let s = Circle(Point { x: 1f, y: 2f }, 3f);
|
||||||
printfln!("%f", s.area(s));
|
println!("{}", s.area(s));
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ struct S {
|
|||||||
|
|
||||||
impl T for S {
|
impl T for S {
|
||||||
fn print(&self) {
|
fn print(&self) {
|
||||||
printfln!(self);
|
println!("{:?}", self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
type ErrPrinter = &fn(&str, &str);
|
type ErrPrinter = &fn(&str, &str);
|
||||||
|
|
||||||
fn example_err(prog: &str, arg: &str) {
|
fn example_err(prog: &str, arg: &str) {
|
||||||
printfln!("%s: %s", prog, arg)
|
println!("{}: {}", prog, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exit(+print: ErrPrinter, prog: &str, arg: &str) {
|
fn exit(+print: ErrPrinter, prog: &str, arg: &str) {
|
||||||
|
@ -114,7 +114,6 @@ fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result {
|
|||||||
//io::println(cmd);
|
//io::println(cmd);
|
||||||
sb.write_str(cmd);
|
sb.write_str(cmd);
|
||||||
let res = parse_response(@sb as @io::Reader);
|
let res = parse_response(@sb as @io::Reader);
|
||||||
//printfln!(res);
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +121,7 @@ fn query2(cmd: ~[~str]) -> Result {
|
|||||||
let _cmd = cmd_to_str(cmd);
|
let _cmd = cmd_to_str(cmd);
|
||||||
do io::with_str_reader(~"$3\r\nXXX\r\n") |sb| {
|
do io::with_str_reader(~"$3\r\nXXX\r\n") |sb| {
|
||||||
let res = parse_response(@sb as @io::Reader);
|
let res = parse_response(@sb as @io::Reader);
|
||||||
printfln!(res);
|
println!("{:?}", res);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ pub fn main() {
|
|||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
assert_eq!(count, 999_999);
|
assert_eq!(count, 999_999);
|
||||||
printfln!("%u", count);
|
println!("{}", count);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,6 @@ static mut frobulator: uint = 0xdeadbeef;
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
frobulator = 0xcafebabe;
|
frobulator = 0xcafebabe;
|
||||||
printfln!("%? %? %?", i_live_in_more_text(), magic, frobulator);
|
println!("{} {} {}", i_live_in_more_text(), magic, frobulator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,5 @@ fn Foo(x: int, y: int) -> Foo {
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let foo = Foo(3, 20);
|
let foo = Foo(3, 20);
|
||||||
printfln!("%d %d", foo.sum(), foo.product());
|
println!("{} {}", foo.sum(), foo.product());
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ use std::io::println;
|
|||||||
static FOO: int = 3;
|
static FOO: int = 3;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
printfln!("%d", FOO);
|
println!("{}", FOO);
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::io::println;
|
|
||||||
|
|
||||||
static FOO: [int, ..3] = [1, 2, 3];
|
static FOO: [int, ..3] = [1, 2, 3];
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
printfln!("%d %d %d", FOO[0], FOO[1], FOO[2]);
|
println!("{} {} {}", FOO[0], FOO[1], FOO[2]);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ fn compute(i: mytype) -> int { return i.val + 20; }
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let myval = mytype(Mytype{compute: compute, val: 30});
|
let myval = mytype(Mytype{compute: compute, val: 30});
|
||||||
printfln!("%d", compute(myval));
|
println!("{}", compute(myval));
|
||||||
assert_eq!((myval.compute)(myval), 50);
|
assert_eq!((myval.compute)(myval), 50);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ pub fn main() {
|
|||||||
let mut arena = Arena::new();
|
let mut arena = Arena::new();
|
||||||
let p = &mut arena;
|
let p = &mut arena;
|
||||||
let x = p.alloc(|| 4u);
|
let x = p.alloc(|| 4u);
|
||||||
printf!("%u", *x);
|
println!("{}", *x);
|
||||||
assert_eq!(*x, 4u);
|
assert_eq!(*x, 4u);
|
||||||
}
|
}
|
||||||
|
@ -30,5 +30,5 @@ fn test<T:Dot> (n:int, i:int, first:T, second:T) ->int {
|
|||||||
}
|
}
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let n = test(1, 0, Nil, Nil);
|
let n = test(1, 0, Nil, Nil);
|
||||||
printfln!("%d", n);
|
println!("{}", n);
|
||||||
}
|
}
|
||||||
|
@ -647,9 +647,9 @@ pub fn main() {
|
|||||||
|
|
||||||
let r = u.vals.clone();
|
let r = u.vals.clone();
|
||||||
for s in r.iter() {
|
for s in r.iter() {
|
||||||
printfln!("val: %s", *s);
|
println!("val: {}", *s);
|
||||||
}
|
}
|
||||||
error!("%?", u.vals.clone());
|
error2!("{:?}", u.vals.clone());
|
||||||
assert_eq!(u.vals.clone(),
|
assert_eq!(u.vals.clone(),
|
||||||
~[ ~"1", ~"2", ~"3", ~"true", ~"false", ~"5", ~"4", ~"3", ~"12"]);
|
~[ ~"1", ~"2", ~"3", ~"true", ~"false", ~"5", ~"4", ~"3", ~"12"]);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ pub fn main() {
|
|||||||
visit_ty::<~[int]>(&mut v);
|
visit_ty::<~[int]>(&mut v);
|
||||||
|
|
||||||
for s in v.types.iter() {
|
for s in v.types.iter() {
|
||||||
printfln!("type: %s", (*s).clone());
|
println!("type: {}", (*s).clone());
|
||||||
}
|
}
|
||||||
assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]);
|
assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ struct Foo {
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let a = Foo { x: 1, y: 2 };
|
let a = Foo { x: 1, y: 2 };
|
||||||
match a {
|
match a {
|
||||||
Foo { x: x, y: y } => printfln!("yes, %d, %d", x, y)
|
Foo { x: x, y: y } => println!("yes, {}, {}", x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ impl FloatExt for f64 {}
|
|||||||
impl FloatExt for float {}
|
impl FloatExt for float {}
|
||||||
|
|
||||||
|
|
||||||
fn test_float_ext<T:FloatExt>(n: T) { printfln!(n < n) }
|
fn test_float_ext<T:FloatExt>(n: T) { println!("{}", n < n) }
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
test_float_ext(1f32);
|
test_float_ext(1f32);
|
||||||
|
@ -16,7 +16,7 @@ pub trait NumExt: Eq + Ord + Num + NumCast {}
|
|||||||
impl NumExt for f32 {}
|
impl NumExt for f32 {}
|
||||||
|
|
||||||
fn num_eq_one<T:NumExt>(n: T) {
|
fn num_eq_one<T:NumExt>(n: T) {
|
||||||
printfln!(n == NumCast::from(1))
|
println!("{}", n == NumCast::from(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
@ -12,5 +12,5 @@ struct Foo(int, int);
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = Foo(1, 2);
|
let x = Foo(1, 2);
|
||||||
printfln!(x);
|
println!("{:?}", x);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ struct Foo(int, int);
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = Foo(1, 2);
|
let x = Foo(1, 2);
|
||||||
let Foo(y, z) = x;
|
let Foo(y, z) = x;
|
||||||
printfln!("%d %d", y, z);
|
println!("{} {}", y, z);
|
||||||
assert_eq!(y, 1);
|
assert_eq!(y, 1);
|
||||||
assert_eq!(z, 2);
|
assert_eq!(z, 2);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ pub fn main() {
|
|||||||
Foo(a, b) => {
|
Foo(a, b) => {
|
||||||
assert_eq!(a, 1);
|
assert_eq!(a, 1);
|
||||||
assert_eq!(b, 2);
|
assert_eq!(b, 2);
|
||||||
printfln!("%d %d", a, b);
|
println!("{} {}", a, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,5 @@
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x: [int, ..4] = [1, 2, 3, 4];
|
let x: [int, ..4] = [1, 2, 3, 4];
|
||||||
printfln!("%d", x[0]);
|
println!("{}", x[0]);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ pub fn main() {
|
|||||||
[1, ..ref tail] => &tail[0],
|
[1, ..ref tail] => &tail[0],
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
};
|
};
|
||||||
printfln!("%d", *el);
|
println!("{}", *el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user