Skip to content

Commit e94e82c

Browse files
bstriecatamorphism
authored andcommitted
Extraneous sigil patrol: ~"string literals"
1 parent 5cf0c65 commit e94e82c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

doc/tutorial.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ and [`core::str`]. Here are some examples.
15021502
# fn unwrap_crayon(c: Crayon) -> int { 0 }
15031503
# fn eat_crayon_wax(i: int) { }
15041504
# fn store_crayon_in_nasal_cavity(i: uint, c: Crayon) { }
1505-
# fn crayon_to_str(c: Crayon) -> ~str { ~"" }
1505+
# fn crayon_to_str(c: Crayon) -> &str { "" }
15061506
15071507
let crayons = &[Almond, AntiqueBrass, Apricot];
15081508
@@ -1649,11 +1649,11 @@ callers may pass any kind of closure.
16491649

16501650
~~~~
16511651
fn call_twice(f: fn()) { f(); f(); }
1652-
call_twice(|| { ~"I am an inferred stack closure"; } );
1653-
call_twice(fn&() { ~"I am also a stack closure"; } );
1654-
call_twice(fn@() { ~"I am a managed closure"; });
1655-
call_twice(fn~() { ~"I am an owned closure"; });
1656-
fn bare_function() { ~"I am a plain function"; }
1652+
call_twice(|| { "I am an inferred stack closure"; } );
1653+
call_twice(fn&() { "I am also a stack closure"; } );
1654+
call_twice(fn@() { "I am a managed closure"; });
1655+
call_twice(fn~() { "I am an owned closure"; });
1656+
fn bare_function() { "I am a plain function"; }
16571657
call_twice(bare_function);
16581658
~~~~
16591659

@@ -1767,7 +1767,7 @@ And using this function to iterate over a vector:
17671767
# use println = io::println;
17681768
each(&[2, 4, 8, 5, 16], |n| {
17691769
if *n % 2 != 0 {
1770-
println(~"found odd number!");
1770+
println("found odd number!");
17711771
false
17721772
} else { true }
17731773
});
@@ -1784,7 +1784,7 @@ to the next iteration, write `loop`.
17841784
# use println = io::println;
17851785
for each(&[2, 4, 8, 5, 16]) |n| {
17861786
if *n % 2 != 0 {
1787-
println(~"found odd number!");
1787+
println("found odd number!");
17881788
break;
17891789
}
17901790
}
@@ -1967,12 +1967,12 @@ impl int: Printable {
19671967
fn print() { io::println(fmt!("%d", self)) }
19681968
}
19691969
1970-
impl ~str: Printable {
1970+
impl &str: Printable {
19711971
fn print() { io::println(self) }
19721972
}
19731973
19741974
# 1.print();
1975-
# (~"foo").print();
1975+
# ("foo").print();
19761976
~~~~
19771977

19781978
Methods defined in an implementation of a trait may be called just like
@@ -2162,8 +2162,8 @@ additional modules.
21622162

21632163
~~~~
21642164
mod farm {
2165-
pub fn chicken() -> ~str { ~"cluck cluck" }
2166-
pub fn cow() -> ~str { ~"mooo" }
2165+
pub fn chicken() -> &str { "cluck cluck" }
2166+
pub fn cow() -> &str { "mooo" }
21672167
}
21682168
21692169
fn main() {
@@ -2360,13 +2360,13 @@ these two files:
23602360
~~~~
23612361
// world.rs
23622362
#[link(name = "world", vers = "1.0")];
2363-
pub fn explore() -> ~str { ~"world" }
2363+
pub fn explore() -> &str { "world" }
23642364
~~~~
23652365

23662366
~~~~ {.xfail-test}
23672367
// main.rs
23682368
extern mod world;
2369-
fn main() { io::println(~"hello " + world::explore()); }
2369+
fn main() { io::println("hello " + world::explore()); }
23702370
~~~~
23712371

23722372
Now compile and run like this (adjust to your platform if necessary):

0 commit comments

Comments
 (0)