@@ -100,7 +100,7 @@ fn main() {
100
100
// Report the results as the games complete
101
101
for range(0, times) |round| {
102
102
let winner = result_from_game.recv();
103
- println(# fmt("%s wins round #%u", winner, round));
103
+ println(fmt! ("%s wins round #%u", winner, round));
104
104
}
105
105
106
106
fn play_game(player1: ~str, player2: ~str) -> ~str {
@@ -650,7 +650,7 @@ one is `#fmt`, a printf-style text formatting macro that is expanded
650
650
at compile time.
651
651
652
652
~~~~
653
- io::println(# fmt("%s is %d", ~"the answer", 42));
653
+ io::println(fmt! ("%s is %d", ~"the answer", 42));
654
654
~~~~
655
655
656
656
` #fmt ` supports most of the directives that [ printf] [ pf ] supports, but
@@ -664,7 +664,7 @@ All syntax extensions look like `#word`. Another built-in one is
664
664
compile-time.
665
665
666
666
~~~~
667
- io::println(# env("PATH"));
667
+ io::println(env! ("PATH"));
668
668
~~~~
669
669
670
670
# Control structures
@@ -908,8 +908,8 @@ and will log the formatted string:
908
908
909
909
~~~~
910
910
# fn get_error_string() -> ~str { ~"boo" }
911
- # warn("only %d seconds remaining", 10);
912
- # error("fatal: %s", get_error_string());
911
+ warn! ("only %d seconds remaining", 10);
912
+ error! ("fatal: %s", get_error_string());
913
913
~~~~
914
914
915
915
Because the macros ` #debug ` , ` #warn ` , and ` #error ` expand to calls to ` log ` ,
@@ -1578,7 +1578,7 @@ the enclosing scope.
1578
1578
fn call_closure_with_ten(b: fn(int)) { b(10); }
1579
1579
1580
1580
let captured_var = 20;
1581
- let closure = |arg| println(# fmt("captured_var=%d, arg=%d", captured_var, arg));
1581
+ let closure = |arg| println(fmt! ("captured_var=%d, arg=%d", captured_var, arg));
1582
1582
1583
1583
call_closure_with_ten(closure);
1584
1584
~~~~
@@ -1706,7 +1706,7 @@ structure.
1706
1706
# fn each(v: ~[int], op: fn(int)) {}
1707
1707
# fn do_some_work(i: int) { }
1708
1708
each(~[1, 2, 3], |n| {
1709
- # debug("%i", n);
1709
+ debug! ("%i", n);
1710
1710
do_some_work(n);
1711
1711
});
1712
1712
~~~~
@@ -1718,7 +1718,7 @@ call that can be written more like a built-in control structure:
1718
1718
# fn each(v: ~[int], op: fn(int)) {}
1719
1719
# fn do_some_work(i: int) { }
1720
1720
do each(~[1, 2, 3]) |n| {
1721
- # debug("%i", n);
1721
+ debug! ("%i", n);
1722
1722
do_some_work(n);
1723
1723
}
1724
1724
~~~~
@@ -1735,7 +1735,7 @@ takes a final closure argument.
1735
1735
import task::spawn;
1736
1736
1737
1737
do spawn() || {
1738
- # debug("I'm a task, whatever");
1738
+ debug! ("I'm a task, whatever");
1739
1739
}
1740
1740
~~~~
1741
1741
@@ -1746,7 +1746,7 @@ there?
1746
1746
~~~~
1747
1747
# import task::spawn;
1748
1748
do spawn {
1749
- # debug("Kablam!");
1749
+ debug! ("Kablam!");
1750
1750
}
1751
1751
~~~~
1752
1752
@@ -2558,7 +2558,7 @@ extern mod crypto {
2558
2558
2559
2559
fn as_hex(data: ~[u8]) -> ~str {
2560
2560
let mut acc = ~"";
2561
- for data.each |byte| { acc += # fmt("%02x", byte as uint); }
2561
+ for data.each |byte| { acc += fmt! ("%02x", byte as uint); }
2562
2562
return acc;
2563
2563
}
2564
2564
@@ -2759,7 +2759,7 @@ fn unix_time_in_microseconds() -> u64 unsafe {
2759
2759
return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
2760
2760
}
2761
2761
2762
- # fn main() { assert # fmt("%?", unix_time_in_microseconds()) != ~""; }
2762
+ # fn main() { assert fmt! ("%?", unix_time_in_microseconds()) != ~""; }
2763
2763
~~~~
2764
2764
2765
2765
The ` #[nolink] ` attribute indicates that there's no foreign library to
@@ -2799,7 +2799,7 @@ let some_value = 22;
2799
2799
2800
2800
do spawn {
2801
2801
println(~"This executes in the child task.");
2802
- println(# fmt("%d", some_value));
2802
+ println(fmt! ("%d", some_value));
2803
2803
}
2804
2804
~~~~
2805
2805
0 commit comments