Skip to content

Commit e9848c4

Browse files
committed
---
yaml --- r: 156638 b: refs/heads/try c: f358407 h: refs/heads/master v: v3
1 parent 2b1c3b1 commit e9848c4

File tree

370 files changed

+12964
-1496
lines changed

Some content is hidden

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

370 files changed

+12964
-1496
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: a34b8dec697014f15e725215e17ea8d956c0ab1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: d44ea720fa9dfe062ef06d0eb49a58d4e7e92344
5-
refs/heads/try: b2e577365512433d17e68107a068fb82af88a67b
5+
refs/heads/try: f358407dcfe4cb50a65110aad31bf88c87e72d39
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 6601b0501e31d08d3892a2d5a7d8a57ab120bf75

branches/try/mk/crates.mk

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
# automatically generated for all stage/host/target combinations.
5050
################################################################################
5151

52-
TARGET_CRATES := libc std green native flate arena term \
53-
serialize sync getopts collections test time rand \
54-
log regex graphviz core rbml rlibc alloc rustrt \
52+
TARGET_CRATES := libc std green native flate arena glob term semver \
53+
uuid serialize sync getopts collections num test time rand \
54+
url log regex graphviz core rbml rlibc alloc rustrt \
5555
unicode
56-
HOST_CRATES := syntax rustc rustdoc regex_macros fmt_macros \
56+
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros \
5757
rustc_llvm rustc_back
5858
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5959
TOOLS := compiletest rustdoc rustc
@@ -83,13 +83,18 @@ DEPS_glob := std
8383
DEPS_serialize := std log
8484
DEPS_rbml := std log serialize
8585
DEPS_term := std log
86+
DEPS_semver := std
87+
DEPS_uuid := std serialize
8688
DEPS_sync := core alloc rustrt collections
8789
DEPS_getopts := std
8890
DEPS_collections := core alloc unicode
91+
DEPS_fourcc := rustc syntax std
92+
DEPS_hexfloat := rustc syntax std
8993
DEPS_num := std
9094
DEPS_test := std getopts serialize rbml term time regex native:rust_test_helpers
9195
DEPS_time := std serialize
9296
DEPS_rand := core
97+
DEPS_url := std
9398
DEPS_log := std regex
9499
DEPS_regex := std
95100
DEPS_regex_macros = rustc syntax std regex

branches/try/src/doc/guide-strings.md

Lines changed: 120 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,11 @@ need, and it can make your lifetimes more complex.
9696

9797
## Generic functions
9898

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):
99+
To write a function that's generic over types of strings, use `&str`.
101100

102101
```{rust}
103-
fn some_string_length<T: Str>(x: T) -> uint {
104-
x.as_slice().len()
102+
fn some_string_length(x: &str) -> uint {
103+
x.len()
105104
}
106105
107106
fn main() {
@@ -111,15 +110,12 @@ fn main() {
111110
112111
let s = "Hello, world".to_string();
113112
114-
println!("{}", some_string_length(s));
113+
println!("{}", some_string_length(s.as_slice()));
115114
}
116115
```
117116

118117
Both of these lines will print `12`.
119118

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.
122-
123119
## Comparisons
124120

125121
To compare a String to a constant string, prefer `as_slice()`...
@@ -161,25 +157,93 @@ indexing is basically never what you want to do. The reason is that each
161157
character can be a variable number of bytes. This means that you have to iterate
162158
through the characters anyway, which is a O(n) operation.
163159

164-
To iterate over a string, use the `graphemes()` method on `&str`:
160+
There's 3 basic levels of unicode (and its encodings):
161+
162+
- code units, the underlying data type used to store everything
163+
- code points/unicode scalar values (char)
164+
- graphemes (visible characters)
165+
166+
Rust provides iterators for each of these situations:
167+
168+
- `.bytes()` will iterate over the underlying bytes
169+
- `.chars()` will iterate over the code points
170+
- `.graphemes()` will iterate over each grapheme
171+
172+
Usually, the `graphemes()` method on `&str` is what you want:
165173

166174
```{rust}
167-
let s = "αἰθήρ";
175+
let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé";
168176
169177
for l in s.graphemes(true) {
170178
println!("{}", l);
171179
}
172180
```
173181

182+
This prints:
183+
184+
```{notrust,ignore}
185+
186+
n͈̰̎
187+
i̙̮͚̦
188+
c͚̉
189+
o̼̩̰͗
190+
d͔̆̓ͥ
191+
192+
```
193+
174194
Note that `l` has the type `&str` here, since a single grapheme can consist of
175195
multiple codepoints, so a `char` wouldn't be appropriate.
176196

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:
197+
This will print out each visible character in turn, as you'd expect: first "u͔", then
198+
"n͈̰̎", etc. If you wanted each individual codepoint of each grapheme, you can use `.chars()`:
180199

181200
```{rust}
182-
let s = "αἰθήρ";
201+
let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé";
202+
203+
for l in s.chars() {
204+
println!("{}", l);
205+
}
206+
```
207+
208+
This prints:
209+
210+
```{notrust,ignore}
211+
u
212+
͔
213+
n
214+
̎
215+
͈
216+
̰
217+
i
218+
̙
219+
̮
220+
͚
221+
̦
222+
c
223+
̉
224+
͚
225+
o
226+
͗
227+
̼
228+
̩
229+
̰
230+
d
231+
̆
232+
̓
233+
ͥ
234+
͔
235+
e
236+
́
237+
```
238+
239+
You can see how some of them are combining characters, and therefore the output
240+
looks a bit odd.
241+
242+
If you want the individual byte representation of each codepoint, you can use
243+
`.bytes()`:
244+
245+
```{rust}
246+
let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé";
183247
184248
for l in s.bytes() {
185249
println!("{}", l);
@@ -189,16 +253,50 @@ for l in s.bytes() {
189253
This will print:
190254

191255
```{notrust,ignore}
192-
206
193-
177
194-
225
195-
188
256+
117
257+
205
258+
148
259+
110
260+
204
261+
142
262+
205
263+
136
264+
204
196265
176
197-
206
198-
184
199-
206
266+
105
267+
204
268+
153
269+
204
200270
174
201-
207
271+
205
272+
154
273+
204
274+
166
275+
99
276+
204
277+
137
278+
205
279+
154
280+
111
281+
205
282+
151
283+
204
284+
188
285+
204
286+
169
287+
204
288+
176
289+
100
290+
204
291+
134
292+
205
293+
131
294+
205
295+
165
296+
205
297+
148
298+
101
299+
204
202300
129
203301
```
204302

branches/try/src/doc/guide.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,10 +3095,10 @@ And try to run the test:
30953095

30963096
```{notrust,ignore}
30973097
$ cargo test
3098-
Compiling testing v0.0.1 (file:///home/you/projects/testing)
3099-
/home/you/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`.
3100-
/home/you/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i);
3101-
^~~~~~~~~~~~~~~~~~~~
3098+
Compiling testing v0.0.1 (file:///home/youg/projects/testing)
3099+
/home/youg/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`.
3100+
/home/youg/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i);
3101+
^~~~~~~~~~~~~~~~~~~~
31023102
error: aborting due to previous error
31033103
Build failed, waiting for other jobs to finish...
31043104
Could not compile `testing`.
@@ -3284,11 +3284,11 @@ Let's give it a shot:
32843284
$ cargo test
32853285
Compiling testing v0.0.1 (file:///home/you/projects/testing)
32863286
3287-
running 2 tests
3287+
running 1 test
32883288
test test::test_times_four ... ok
32893289
test test::test_add_three ... ok
32903290
3291-
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
3291+
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
32923292
32933293
32943294
running 0 tests
@@ -4363,7 +4363,7 @@ element, `find` returns an `Option` rather than the element itself.
43634363
Another important consumer is `fold`. Here's what it looks like:
43644364

43654365
```{rust}
4366-
let sum = range(1i, 4i)
4366+
let sum = range(1i, 100i)
43674367
.fold(0i, |sum, x| sum + x);
43684368
```
43694369

@@ -4387,7 +4387,7 @@ in this iterator:
43874387
We called `fold()` with these arguments:
43884388

43894389
```{rust}
4390-
# range(1i, 4i)
4390+
# range(1i, 5i)
43914391
.fold(0i, |sum, x| sum + x);
43924392
```
43934393

branches/try/src/doc/intro.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -442,21 +442,21 @@ It gives us this error:
442442
```
443443

444444
It mentions that "numbers moved into closure environment". Because we referred
445-
to `numbers` inside of our `proc`, and we create three `proc`s, we would have
446-
three references. Rust detects this and gives us the error: we claim that
447-
`numbers` has ownership, but our code tries to make three owners. This may
448-
cause a safety problem, so Rust disallows it.
445+
to `numbers` inside of our `proc`, and we create ten `proc`s, we would have ten
446+
references. Rust detects this and gives us the error: we claim that `numbers`
447+
has ownership, but our code tries to make ten owners. This may cause a safety
448+
problem, so Rust disallows it.
449449

450450
What to do here? Rust has two types that helps us: `Arc<T>` and `Mutex<T>`.
451451
"Arc" stands for "atomically reference counted." In other words, an Arc will
452452
keep track of the number of references to something, and not free the
453453
associated resource until the count is zero. The 'atomic' portion refers to an
454454
Arc's usage of concurrency primitives to atomically update the count, making it
455-
safe across threads. If we use an Arc, we can have our three references. But,
456-
an Arc does not allow mutable borrows of the data it holds, and we want to
457-
modify what we're sharing. In this case, we can use a `Mutex<T>` inside of our
458-
Arc. A Mutex will synchronize our accesses, so that we can ensure that our
459-
mutation doesn't cause a data race.
455+
safe across threads. If we use an Arc, we can have our ten references. But, an
456+
Arc does not allow mutable borrows of the data it holds, and we want to modify
457+
what we're sharing. In this case, we can use a `Mutex<T>` inside of our Arc. A
458+
Mutex will synchronize our accesses, so that we can ensure that our mutation
459+
doesn't cause a data race.
460460

461461
Here's what using an Arc with a Mutex looks like:
462462

branches/try/src/libcollections/dlist.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,12 @@ impl<T> DList<T> {
475475
Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail}
476476
}
477477

478+
/// Deprecated: use `iter_mut`.
479+
#[deprecated = "use iter_mut"]
480+
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
481+
self.iter_mut()
482+
}
483+
478484
/// Provides a forward iterator with mutable references.
479485
#[inline]
480486
pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> {
@@ -490,6 +496,12 @@ impl<T> DList<T> {
490496
}
491497
}
492498

499+
/// Deprecated: use `into_iter`.
500+
#[deprecated = "use into_iter"]
501+
pub fn move_iter(self) -> MoveItems<T> {
502+
self.into_iter()
503+
}
504+
493505
/// Consumes the list into an iterator yielding elements by value.
494506
#[inline]
495507
pub fn into_iter(self) -> MoveItems<T> {
@@ -858,8 +870,7 @@ mod tests {
858870
let mut m = list_from(v.as_slice());
859871
m.append(list_from(u.as_slice()));
860872
check_links(&m);
861-
let mut sum = v;
862-
sum.push_all(u.as_slice());
873+
let sum = v.append(u.as_slice());
863874
assert_eq!(sum.len(), m.len());
864875
for elt in sum.into_iter() {
865876
assert_eq!(m.pop_front(), Some(elt))

branches/try/src/libcollections/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,40 @@ pub trait Deque<T> : MutableSeq<T> {
502502
/// ```
503503
fn push_front(&mut self, elt: T);
504504

505+
/// Inserts an element last in the sequence.
506+
///
507+
/// # Example
508+
///
509+
/// ```ignore
510+
/// use std::collections::{DList, Deque};
511+
///
512+
/// let mut d = DList::new();
513+
/// d.push_back(1i);
514+
/// d.push_back(2i);
515+
/// assert_eq!(d.front(), Some(&1i));
516+
/// ```
517+
#[deprecated = "use the `push` method"]
518+
fn push_back(&mut self, elt: T) { self.push(elt) }
519+
520+
/// Removes the last element and returns it, or `None` if the sequence is
521+
/// empty.
522+
///
523+
/// # Example
524+
///
525+
/// ```ignore
526+
/// use std::collections::{RingBuf, Deque};
527+
///
528+
/// let mut d = RingBuf::new();
529+
/// d.push_back(1i);
530+
/// d.push_back(2i);
531+
///
532+
/// assert_eq!(d.pop_back(), Some(2i));
533+
/// assert_eq!(d.pop_back(), Some(1i));
534+
/// assert_eq!(d.pop_back(), None);
535+
/// ```
536+
#[deprecated = "use the `pop` method"]
537+
fn pop_back(&mut self) -> Option<T> { self.pop() }
538+
505539
/// Removes the first element and returns it, or `None` if the sequence is
506540
/// empty.
507541
///

0 commit comments

Comments
 (0)