Skip to content

Commit 9e4fd5c

Browse files
committed
---
yaml --- r: 130804 b: refs/heads/master c: 6faa4f3 h: refs/heads/master v: v3
1 parent 237bb5b commit 9e4fd5c

File tree

93 files changed

+1109
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1109
-486
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ba43f7bc8c81e595182abdf1698f0a19187c11b5
2+
refs/heads/master: 6faa4f33a42de32579e02a8d030db920d360e2b5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6faa4f33a42de32579e02a8d030db920d360e2b5
55
refs/heads/try: a2473a89da106f7dd3be86e9d52fe23f43d5bfa5

trunk/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ then
707707
| cut -d ' ' -f 2)
708708

709709
case $CFG_CLANG_VERSION in
710-
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 3.4* | 3.5* )
710+
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
711711
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
712712
if [ -z "$CC" ]
713713
then

trunk/mk/dist.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ PKG_EXE = dist/$(PKG_NAME)-install.exe
123123
$(PKG_EXE): rust.iss modpath.iss upgrade.iss LICENSE.txt rust-logo.ico \
124124
$(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
125125
dist-prepare-win
126-
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin
126+
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin $(CFG_BUILD)
127127
@$(call E, ISCC: $@)
128128
$(Q)"$(CFG_ISCC)" $<
129129

trunk/src/doc/guide-strings.md

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,33 @@ fn foo(s: String) {
9292
```
9393

9494
If you have good reason. It's not polite to hold on to ownership you don't
95-
need, and it can make your lifetimes more complex. Furthermore, you can pass
96-
either kind of string into `foo` by using `.as_slice()` on any `String` you
97-
need to pass in, so the `&str` version is more flexible.
95+
need, and it can make your lifetimes more complex.
96+
97+
## Generic functions
98+
99+
To write a function that's generic over types of strings, use [the `Str`
100+
trait](http://doc.rust-lang.org/std/str/trait.Str.html):
101+
102+
```{rust}
103+
fn some_string_length<T: Str>(x: T) -> uint {
104+
x.as_slice().len()
105+
}
106+
107+
fn main() {
108+
let s = "Hello, world";
109+
110+
println!("{}", some_string_length(s));
111+
112+
let s = "Hello, world".to_string();
113+
114+
println!("{}", some_string_length(s));
115+
}
116+
```
117+
118+
Both of these lines will print `12`.
119+
120+
The only method that the `Str` trait has is `as_slice()`, which gives you
121+
access to a `&str` value from the underlying string.
98122

99123
## Comparisons
100124

@@ -121,6 +145,65 @@ fn compare(string: String) {
121145
Converting a `String` to a `&str` is cheap, but converting the `&str` to a
122146
`String` involves an allocation.
123147

148+
## Indexing strings
149+
150+
You may be tempted to try to access a certain character of a `String`, like
151+
this:
152+
153+
```{rust,ignore}
154+
let s = "hello".to_string();
155+
156+
println!("{}", s[0]);
157+
```
158+
159+
This does not compile. This is on purpose. In the world of UTF-8, direct
160+
indexing is basically never what you want to do. The reason is that each
161+
character can be a variable number of bytes. This means that you have to iterate
162+
through the characters anyway, which is a O(n) operation.
163+
164+
To iterate over a string, use the `graphemes()` method on `&str`:
165+
166+
```{rust}
167+
let s = "αἰθήρ";
168+
169+
for l in s.graphemes(true) {
170+
println!("{}", l);
171+
}
172+
```
173+
174+
Note that `l` has the type `&str` here, since a single grapheme can consist of
175+
multiple codepoints, so a `char` wouldn't be appropriate.
176+
177+
This will print out each character in turn, as you'd expect: first "α", then
178+
"ἰ", etc. You can see that this is different than just the individual bytes.
179+
Here's a version that prints out each byte:
180+
181+
```{rust}
182+
let s = "αἰθήρ";
183+
184+
for l in s.bytes() {
185+
println!("{}", l);
186+
}
187+
```
188+
189+
This will print:
190+
191+
```{notrust,ignore}
192+
206
193+
177
194+
225
195+
188
196+
176
197+
206
198+
184
199+
206
200+
174
201+
207
202+
129
203+
```
204+
205+
Many more bytes than graphemes!
206+
124207
# Other Documentation
125208

126209
* [the `&str` API documentation](/std/str/index.html)

trunk/src/doc/guide.md

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ in your file name, use an underscore. `hello_world.rs` versus `goodbye.rs`.
150150

151151
Now that you've got your file open, type this in:
152152

153-
```
153+
```{rust}
154154
fn main() {
155155
println!("Hello, world!");
156156
}
@@ -166,7 +166,7 @@ Hello, world!
166166

167167
Success! Let's go over what just happened in detail.
168168

169-
```
169+
```{rust}
170170
fn main() {
171171
172172
}
@@ -186,7 +186,7 @@ declaration, with one space in between.
186186

187187
Next up is this line:
188188

189-
```
189+
```{rust}
190190
println!("Hello, world!");
191191
```
192192

@@ -520,10 +520,8 @@ error: aborting due to previous error
520520
Could not compile `hello_world`.
521521
```
522522

523-
Rust will not let us use a value that has not been initialized. So why let us
524-
declare a binding without initializing it? You'd think our first example would
525-
have errored. Well, Rust is smarter than that. Before we get to that, let's talk
526-
about this stuff we've added to `println!`.
523+
Rust will not let us use a value that has not been initialized. Next, let's
524+
talk about this stuff we've added to `println!`.
527525

528526
If you include two curly braces (`{}`, some call them moustaches...) in your
529527
string to print, Rust will interpret this as a request to interpolate some sort
@@ -538,12 +536,6 @@ format in a more detailed manner, there are a [wide number of options
538536
available](std/fmt/index.html). For now, we'll just stick to the default:
539537
integers aren't very complicated to print.
540538

541-
So, we've cleared up all of the confusion around bindings, with one exception:
542-
why does Rust let us declare a variable binding without an initial value if we
543-
must initialize the binding before we use it? And how does it know that we have
544-
or have not initialized the binding? For that, we need to learn our next
545-
concept: `if`.
546-
547539
# If
548540

549541
Rust's take on `if` is not particularly complex, but it's much more like the
@@ -570,7 +562,7 @@ the block is executed. If it's `false`, then it is not.
570562

571563
If you want something to happen in the `false` case, use an `else`:
572564

573-
```
565+
```{rust}
574566
let x = 5i;
575567
576568
if x == 5i {
@@ -583,7 +575,7 @@ if x == 5i {
583575
This is all pretty standard. However, you can also do this:
584576

585577

586-
```
578+
```{rust}
587579
let x = 5i;
588580
589581
let y = if x == 5i {
@@ -595,7 +587,7 @@ let y = if x == 5i {
595587

596588
Which we can (and probably should) write like this:
597589

598-
```
590+
```{rust}
599591
let x = 5i;
600592
601593
let y = if x == 5i { 10i } else { 15i };
@@ -652,7 +644,7 @@ every line of Rust code you see.
652644
What is this exception that makes us say 'almost?' You saw it already, in this
653645
code:
654646

655-
```
647+
```{rust}
656648
let x = 5i;
657649
658650
let y: int = if x == 5i { 10i } else { 15i };
@@ -998,7 +990,7 @@ notation: `origin.x`.
998990
The values in structs are immutable, like other bindings in Rust. However, you
999991
can use `mut` to make them mutable:
1000992

1001-
```rust
993+
```{rust}
1002994
struct Point {
1003995
x: int,
1004996
y: int,
@@ -1022,7 +1014,7 @@ called a **tuple struct**. Tuple structs do have a name, but their fields
10221014
don't:
10231015

10241016

1025-
```
1017+
```{rust}
10261018
struct Color(int, int, int);
10271019
struct Point(int, int, int);
10281020
```
@@ -1037,7 +1029,7 @@ let origin = Point(0, 0, 0);
10371029
It is almost always better to use a struct than a tuple struct. We would write
10381030
`Color` and `Point` like this instead:
10391031

1040-
```rust
1032+
```{rust}
10411033
struct Color {
10421034
red: int,
10431035
blue: int,
@@ -1058,7 +1050,7 @@ There _is_ one case when a tuple struct is very useful, though, and that's a
10581050
tuple struct with only one element. We call this a 'newtype,' because it lets
10591051
you create a new type that's a synonym for another one:
10601052

1061-
```
1053+
```{rust}
10621054
struct Inches(int);
10631055
10641056
let length = Inches(10);
@@ -1175,7 +1167,7 @@ what's the solution?
11751167
Rust has a keyword, `match`, that allows you to replace complicated `if`/`else`
11761168
groupings with something more powerful. Check it out:
11771169

1178-
```rust
1170+
```{rust}
11791171
let x = 5i;
11801172
11811173
match x {
@@ -1416,7 +1408,7 @@ We now loop forever with `loop`, and use `break` to break out early.
14161408
`continue` is similar, but instead of ending the loop, goes to the next
14171409
iteration: This will only print the odd numbers:
14181410

1419-
```
1411+
```{rust}
14201412
for x in range(0i, 10i) {
14211413
if x % 2 == 0 { continue; }
14221414
@@ -4131,7 +4123,7 @@ the ability to use this **method call syntax** via the `impl` keyword.
41314123

41324124
Here's how it works:
41334125

4134-
```
4126+
```{rust}
41354127
struct Circle {
41364128
x: f64,
41374129
y: f64,
@@ -4170,7 +4162,7 @@ multiplications later, and we have our area.
41704162
You can also define methods that do not take a `self` parameter. Here's a
41714163
pattern that's very common in Rust code:
41724164

4173-
```
4165+
```{rust}
41744166
struct Circle {
41754167
x: f64,
41764168
y: f64,

trunk/src/doc/rust.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,17 +3290,19 @@ between `_` and `..` is that the pattern `C(_)` is only type-correct if `C` has
32903290
exactly one argument, while the pattern `C(..)` is type-correct for any enum
32913291
variant `C`, regardless of how many arguments `C` has.
32923292

3293-
Used inside a vector pattern, `..` stands for any number of elements. This
3294-
wildcard can be used at most once for a given vector, which implies that it
3295-
cannot be used to specifically match elements that are at an unknown distance
3296-
from both ends of a vector, like `[.., 42, ..]`. If followed by a variable name,
3297-
it will bind the corresponding slice to the variable. Example:
3293+
Used inside a vector pattern, `..` stands for any number of elements, when the
3294+
`advanced_slice_patterns` feature gate is turned on. This wildcard can be used
3295+
at most once for a given vector, which implies that it cannot be used to
3296+
specifically match elements that are at an unknown distance from both ends of a
3297+
vector, like `[.., 42, ..]`. If followed by a variable name, it will bind the
3298+
corresponding slice to the variable. Example:
32983299

32993300
~~~~
3301+
# #![feature(advanced_slice_patterns)]
33003302
fn is_symmetric(list: &[uint]) -> bool {
33013303
match list {
33023304
[] | [_] => true,
3303-
[x, ..inside, y] if x == y => is_symmetric(inside),
3305+
[x, inside.., y] if x == y => is_symmetric(inside),
33043306
_ => false
33053307
}
33063308
}

trunk/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,7 @@ let score = match numbers {
17071707
[] => 0,
17081708
[a] => a * 10,
17091709
[a, b] => a * 6 + b * 4,
1710-
[a, b, c, ..rest] => a * 5 + b * 3 + c * 2 + rest.len() as int
1710+
[a, b, c, rest..] => a * 5 + b * 3 + c * 2 + rest.len() as int
17111711
};
17121712
~~~~
17131713

trunk/src/etc/copy-runtime-deps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
import snapshot, sys, os, shutil
1414

15-
def copy_runtime_deps(dest_dir):
16-
for path in snapshot.get_winnt_runtime_deps():
15+
def copy_runtime_deps(dest_dir, triple):
16+
for path in snapshot.get_winnt_runtime_deps(snapshot.get_platform(triple)):
1717
shutil.copy(path, dest_dir)
1818

1919
lic_dest = os.path.join(dest_dir, "third-party")
2020
if os.path.exists(lic_dest):
2121
shutil.rmtree(lic_dest) # copytree() won't overwrite existing files
2222
shutil.copytree(os.path.join(os.path.dirname(__file__), "third-party"), lic_dest)
2323

24-
copy_runtime_deps(sys.argv[1])
24+
copy_runtime_deps(sys.argv[1], sys.argv[2])

trunk/src/etc/licenseck.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@
4343
"libsync/mpmc_bounded_queue.rs", # BSD
4444
"libsync/mpsc_intrusive.rs", # BSD
4545
"test/bench/shootout-binarytrees.rs", # BSD
46+
"test/bench/shootout-chameneos-redux.rs", # BSD
4647
"test/bench/shootout-fannkuch-redux.rs", # BSD
4748
"test/bench/shootout-k-nucleotide.rs", # BSD
4849
"test/bench/shootout-mandelbrot.rs", # BSD
4950
"test/bench/shootout-meteor.rs", # BSD
51+
"test/bench/shootout-nbody.rs", # BSD
5052
"test/bench/shootout-pidigits.rs", # BSD
5153
"test/bench/shootout-regex-dna.rs", # BSD
54+
"test/bench/shootout-reverse-complement.rs", # BSD
5255
"test/bench/shootout-threadring.rs", # BSD
5356
]
5457

trunk/src/etc/snapshot.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ def scrub(b):
3939
"freebsd": ["bin/rustc"],
4040
}
4141

42-
winnt_runtime_deps = ["libgcc_s_dw2-1.dll",
43-
"libstdc++-6.dll"]
42+
winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll",
43+
"libstdc++-6.dll"]
44+
winnt_runtime_deps_64 = ["libgcc_s_seh-1.dll",
45+
"libstdc++-6.dll"]
4446

4547
def parse_line(n, line):
4648
global snapshotfile
@@ -146,10 +148,14 @@ def hash_file(x):
146148
return scrub(h.hexdigest())
147149

148150
# Returns a list of paths of Rust's system runtime dependencies
149-
def get_winnt_runtime_deps():
151+
def get_winnt_runtime_deps(platform):
152+
if platform == "winnt-x86_64":
153+
deps = winnt_runtime_deps_64
154+
else:
155+
deps = winnt_runtime_deps_32
150156
runtime_deps = []
151-
path_dirs = os.environ["PATH"].split(';')
152-
for name in winnt_runtime_deps:
157+
path_dirs = os.environ["PATH"].split(os.pathsep)
158+
for name in deps:
153159
for dir in path_dirs:
154160
matches = glob.glob(os.path.join(dir, name))
155161
if matches:
@@ -189,7 +195,7 @@ def in_tar_name(fn):
189195
"Please make a clean build." % "\n ".join(matches))
190196

191197
if kernel=="winnt":
192-
for path in get_winnt_runtime_deps():
198+
for path in get_winnt_runtime_deps(platform):
193199
tar.add(path, "rust-stage0/bin/" + os.path.basename(path))
194200
tar.add(os.path.join(os.path.dirname(__file__), "third-party"),
195201
"rust-stage0/bin/third-party")

trunk/src/jemalloc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 024c67ad651e1a3ca228936c4cfb13a37329baf2
1+
Subproject commit aae04170ccbfeea620502106b581c3c216cd132a

0 commit comments

Comments
 (0)