@@ -449,7 +449,7 @@ Two examples of paths with type arguments:
449
449
# import std::map;
450
450
# fn f() {
451
451
# fn id<T:copy>(t: T) -> T { t }
452
- type t = map::hashmap<int,str>; // Type arguments used in a type expression
452
+ type t = map::hashmap<int,~ str>; // Type arguments used in a type expression
453
453
let x = id::<int>(10); // Type arguments used in a call expression
454
454
# }
455
455
~~~~
@@ -563,7 +563,7 @@ a referencing crate file, or by the filename of the source file itself.
563
563
564
564
A source file that contains a ` main ` function can be compiled to an
565
565
executable. If a ` main ` function is present, it must have no [ type parameters] ( #type-parameters )
566
- and no [ constraints] ( #constraints ) . Its return type must be [ ` nil ` ] ( #primitive-types ) and it must either have no arguments, or a single argument of type ` [str] ` .
566
+ and no [ constraints] ( #constraints ) . Its return type must be [ ` nil ` ] ( #primitive-types ) and it must either have no arguments, or a single argument of type ` [~ str] ` .
567
567
568
568
# Items and attributes
569
569
@@ -745,8 +745,8 @@ fn main() {
745
745
log(info, some(1.0));
746
746
747
747
// Equivalent to 'log(core::info,
748
- // core::str::hash(core::str::slice("foo", 0u, 1u)));'
749
- log(info, hash(slice("foo", 0u, 1u)));
748
+ // core::str::hash(core::str::slice(~ "foo", 0u, 1u)));'
749
+ log(info, hash(slice(~ "foo", 0u, 1u)));
750
750
}
751
751
~~~~
752
752
@@ -861,7 +861,7 @@ A special kind of function can be declared with a `!` character where the
861
861
output slot type would normally be. For example:
862
862
863
863
~~~~
864
- fn my_err(s: str) -> ! {
864
+ fn my_err(s: ~ str) -> ! {
865
865
log(info, s);
866
866
fail;
867
867
}
@@ -881,14 +881,14 @@ were declared without the `!` annotation, the following code would not
881
881
typecheck:
882
882
883
883
~~~~
884
- # fn my_err(s: str) -> ! { fail }
884
+ # fn my_err(s: ~ str) -> ! { fail }
885
885
886
886
fn f(i: int) -> int {
887
887
if i == 42 {
888
888
ret 42;
889
889
}
890
890
else {
891
- my_err("Bad number!");
891
+ my_err(~ "Bad number!");
892
892
}
893
893
}
894
894
~~~~
@@ -1497,7 +1497,7 @@ string, boolean value, or the nil value.
1497
1497
1498
1498
~~~~~~~~ {.literals}
1499
1499
(); // nil type
1500
- "hello"; // string type
1500
+ ~ "hello"; // string type
1501
1501
'5'; // character type
1502
1502
5; // integer type
1503
1503
~~~~~~~~
@@ -1510,7 +1510,7 @@ values.
1510
1510
1511
1511
~~~~~~~~ {.tuple}
1512
1512
(0f, 4.5f);
1513
- ("a", 4u, true);
1513
+ (~ "a", 4u, true);
1514
1514
~~~~~~~~
1515
1515
1516
1516
### Record expressions
@@ -1529,8 +1529,8 @@ written before its name.
1529
1529
1530
1530
~~~~
1531
1531
{x: 10f, y: 20f};
1532
- {name: "Joe", age: 35u, score: 100_000};
1533
- {ident: "X", mut count: 0u};
1532
+ {name: ~ "Joe", age: 35u, score: 100_000};
1533
+ {ident: ~ "X", mut count: 0u};
1534
1534
~~~~
1535
1535
1536
1536
The order of the fields in a record expression is significant, and
@@ -1594,7 +1594,7 @@ When no mutability is specified, the vector is immutable.
1594
1594
1595
1595
~~~~
1596
1596
~[1, 2, 3, 4];
1597
- ~["a", "b", "c", "d"];
1597
+ ~[~ "a", ~ "b", ~ "c", ~ "d"];
1598
1598
~[mut 0u8, 0u8, 0u8, 0u8];
1599
1599
~~~~
1600
1600
@@ -1620,7 +1620,7 @@ task in a _failing state_.
1620
1620
1621
1621
(~[1, 2, 3, 4])[0];
1622
1622
(~[mut 'x', 'y'])[1] = 'z';
1623
- (~["a", "b"])[10]; // fails
1623
+ (~[~ "a", ~ "b"])[10]; // fails
1624
1624
1625
1625
# }
1626
1626
~~~~
@@ -1965,7 +1965,7 @@ An example:
1965
1965
# let println = io::println;
1966
1966
1967
1967
while i < 10 {
1968
- println("hello\n");
1968
+ println(~ "hello\n");
1969
1969
i = i + 1;
1970
1970
}
1971
1971
~~~~
@@ -2103,9 +2103,9 @@ enum list<X> { nil, cons(X, @list<X>) }
2103
2103
let x: list<int> = cons(10, @cons(11, @nil));
2104
2104
2105
2105
alt x {
2106
- cons(_, @nil) { fail "singleton list"; }
2106
+ cons(_, @nil) { fail ~ "singleton list"; }
2107
2107
cons(*) { ret; }
2108
- nil { fail "empty list"; }
2108
+ nil { fail ~ "empty list"; }
2109
2109
}
2110
2110
~~~~
2111
2111
@@ -2152,28 +2152,28 @@ When matching fields of a record, the fields being matched are specified
2152
2152
first, then a placeholder (` _ ` ) represents the remaining fields.
2153
2153
2154
2154
~~~~
2155
- # type options = {choose: bool, size: str};
2156
- # type player = {player: str, stats: (), options: options};
2155
+ # type options = {choose: bool, size: ~ str};
2156
+ # type player = {player: ~ str, stats: (), options: options};
2157
2157
# fn load_stats() { }
2158
2158
# fn choose_player(r: player) { }
2159
2159
# fn next_player() { }
2160
2160
2161
2161
fn main() {
2162
2162
let r = {
2163
- player: "ralph",
2163
+ player: ~ "ralph",
2164
2164
stats: load_stats(),
2165
2165
options: {
2166
2166
choose: true,
2167
- size: "small"
2167
+ size: ~ "small"
2168
2168
}
2169
2169
};
2170
2170
2171
2171
alt r {
2172
2172
{options: {choose: true, _}, _} {
2173
2173
choose_player(r)
2174
2174
}
2175
- {player: p, options: {size: "small", _}, _} {
2176
- log(info, p + " is small");
2175
+ {player: p, options: {size: ~ "small", _}, _} {
2176
+ log(info, p + ~ " is small");
2177
2177
}
2178
2178
_ {
2179
2179
next_player();
@@ -2189,9 +2189,9 @@ range of values may be specified with `to`. For example:
2189
2189
# let x = 2;
2190
2190
2191
2191
let message = alt x {
2192
- 0 | 1 { "not many" }
2193
- 2 to 9 { "a few" }
2194
- _ { "lots" }
2192
+ 0 | 1 { ~ "not many" }
2193
+ 2 to 9 { ~ "a few" }
2194
+ _ { ~ "lots" }
2195
2195
};
2196
2196
~~~~
2197
2197
@@ -2250,9 +2250,9 @@ the `note` to the internal logging diagnostic buffer.
2250
2250
An example of a ` note ` expression:
2251
2251
2252
2252
~~~~ {.xfail-test}
2253
- fn read_file_lines(path: str) -> ~[str] {
2253
+ fn read_file_lines(path: ~ str) -> ~[~ str] {
2254
2254
note path;
2255
- let r: [str];
2255
+ let r: [~ str];
2256
2256
let f: file = open_read(path);
2257
2257
lines(f) |s| {
2258
2258
r += ~[s];
@@ -2323,13 +2323,13 @@ The following examples all produce the same output, logged at the `error`
2323
2323
logging level:
2324
2324
2325
2325
~~~~
2326
- # let filename = "bulbasaur";
2326
+ # let filename = ~ "bulbasaur";
2327
2327
2328
2328
// Full version, logging a value.
2329
- log(core::error, "file not found: " + filename);
2329
+ log(core::error, ~ "file not found: " + filename);
2330
2330
2331
2331
// Log-level abbreviated, since core::* is imported by default.
2332
- log(error, "file not found: " + filename);
2332
+ log(error, ~ "file not found: " + filename);
2333
2333
2334
2334
// Formatting the message using a format-string and #fmt
2335
2335
log(error, #fmt("file not found: %s", filename));
@@ -2627,12 +2627,12 @@ type `float` may not be equal to the largest *supported* floating-point type.
2627
2627
2628
2628
### Textual types
2629
2629
2630
- The types ` char ` and ` str ` hold textual data.
2630
+ The types ` char ` and ` ~ str` hold textual data.
2631
2631
2632
2632
A value of type ` char ` is a Unicode character, represented as a 32-bit
2633
2633
unsigned word holding a UCS-4 codepoint.
2634
2634
2635
- A value of type ` str ` is a Unicode string, represented as a vector of 8-bit
2635
+ A value of type ` ~ str` is a Unicode string, represented as a vector of 8-bit
2636
2636
unsigned bytes holding a sequence of UTF-8 codepoints.
2637
2637
2638
2638
@@ -2670,10 +2670,10 @@ order specified by the tuple type.
2670
2670
An example of a tuple type and its use:
2671
2671
2672
2672
~~~~
2673
- type pair = (int,str);
2674
- let p: pair = (10,"hello");
2673
+ type pair = (int,~ str);
2674
+ let p: pair = (10,~ "hello");
2675
2675
let (a, b) = p;
2676
- assert b != "world";
2676
+ assert b != ~ "world";
2677
2677
~~~~
2678
2678
2679
2679
### Vector types
@@ -2837,7 +2837,7 @@ For example, this code:
2837
2837
~~~~~~~~
2838
2838
# let mut s;
2839
2839
2840
- s = "hello, world";
2840
+ s = ~ "hello, world";
2841
2841
io::println(s);
2842
2842
~~~~~~~~
2843
2843
@@ -2862,8 +2862,8 @@ Whereas this code:
2862
2862
2863
2863
2864
2864
~~~~~~~~
2865
- # fn x() -> str { "" }
2866
- # fn y() -> str { "" }
2865
+ # fn x() -> ~ str { ~ "" }
2866
+ # fn y() -> ~ str { ~ "" }
2867
2867
2868
2868
io::println(x() + y());
2869
2869
~~~~~~~~
@@ -3364,7 +3364,7 @@ An example of a send:
3364
3364
~~~~
3365
3365
let po = comm::port();
3366
3366
let ch = comm::chan(po);
3367
- comm::send(ch, "hello, world");
3367
+ comm::send(ch, ~ "hello, world");
3368
3368
~~~~
3369
3369
3370
3370
@@ -3380,7 +3380,7 @@ An example of a *receive*:
3380
3380
~~~~~~~~
3381
3381
# let po = comm::port();
3382
3382
# let ch = comm::chan(po);
3383
- # comm::send(ch, "");
3383
+ # comm::send(ch, ~ "");
3384
3384
let s = comm::recv(po);
3385
3385
~~~~~~~~
3386
3386
0 commit comments