Skip to content

Commit 401e663

Browse files
committed
---
yaml --- r: 69326 b: refs/heads/auto c: f73bb2b h: refs/heads/master v: v3
1 parent d1e02a5 commit 401e663

File tree

171 files changed

+2281
-1606
lines changed

Some content is hidden

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

171 files changed

+2281
-1606
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 9a950802ed01ac2e7d7e04cb9df0519245551393
17+
refs/heads/auto: f73bb2bfe637b7e0edd8086fe8ba45032d8e3320
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/doc/tutorial-container.md

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ let mut it = xs.iter().zip(ys.iter());
192192

193193
// print out the pairs of elements up to (&3, &"baz")
194194
for it.advance |(x, y)| {
195-
println(fmt!("%d %s", *x, *y));
195+
printfln!("%d %s", *x, *y);
196196

197197
if *x == 3 {
198198
break;
199199
}
200200
}
201201

202202
// yield and print the last pair from the iterator
203-
println(fmt!("last: %?", it.next()));
203+
printfln!("last: %?", it.next());
204204

205205
// the iterator is now fully consumed
206206
assert!(it.next().is_none());
@@ -294,15 +294,59 @@ another `DoubleEndedIterator` with `next` and `next_back` exchanged.
294294
~~~
295295
let xs = [1, 2, 3, 4, 5, 6];
296296
let mut it = xs.iter();
297-
println(fmt!("%?", it.next())); // prints `Some(&1)`
298-
println(fmt!("%?", it.next())); // prints `Some(&2)`
299-
println(fmt!("%?", it.next_back())); // prints `Some(&6)`
297+
printfln!("%?", it.next()); // prints `Some(&1)`
298+
printfln!("%?", it.next()); // prints `Some(&2)`
299+
printfln!("%?", it.next_back()); // prints `Some(&6)`
300300

301301
// prints `5`, `4` and `3`
302302
for it.invert().advance |&x| {
303-
println(fmt!("%?", x))
303+
printfln!("%?", x)
304304
}
305305
~~~
306306
307307
The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted
308308
version of the standard immutable and mutable vector iterators.
309+
310+
The `chain_`, `transform`, `filter`, `filter_map` and `peek` adaptors are
311+
`DoubleEndedIterator` implementations if the underlying iterators are.
312+
313+
~~~
314+
let xs = [1, 2, 3, 4];
315+
let ys = [5, 6, 7, 8];
316+
let mut it = xs.iter().chain_(ys.iter()).transform(|&x| x * 2);
317+
318+
printfln!("%?", it.next()); // prints `Some(2)`
319+
320+
// prints `16`, `14`, `12`, `10`, `8`, `6`, `4`
321+
for it.invert().advance |x| {
322+
printfln!("%?", x);
323+
}
324+
~~~
325+
326+
## Random-access iterators
327+
328+
The `RandomAccessIterator` trait represents an iterator offering random access
329+
to the whole range. The `indexable` method retrieves the number of elements
330+
accessible with the `idx` method.
331+
332+
The `chain_` adaptor is an implementation of `RandomAccessIterator` if the
333+
underlying iterators are.
334+
335+
~~~
336+
let xs = [1, 2, 3, 4, 5];
337+
let ys = ~[7, 9, 11];
338+
let mut it = xs.iter().chain_(ys.iter());
339+
printfln!("%?", it.idx(0)); // prints `Some(&1)`
340+
printfln!("%?", it.idx(5)); // prints `Some(&7)`
341+
printfln!("%?", it.idx(7)); // prints `Some(&11)`
342+
printfln!("%?", it.idx(8)); // prints `None`
343+
344+
// yield two elements from the beginning, and one from the end
345+
it.next();
346+
it.next();
347+
it.next_back();
348+
349+
printfln!("%?", it.idx(0)); // prints `Some(&3)`
350+
printfln!("%?", it.idx(4)); // prints `Some(&9)`
351+
printfln!("%?", it.idx(6)); // prints `None`
352+
~~~

branches/auto/doc/tutorial.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ types.
499499
> items.
500500
501501
~~~~
502-
# use std::float;
503-
# use std::num::atan;
502+
use std::float;
503+
use std::num::atan;
504504
fn angle(vector: (float, float)) -> float {
505505
let pi = float::consts::pi;
506506
match vector {
@@ -555,7 +555,7 @@ while cake_amount > 0 {
555555
`loop` denotes an infinite loop, and is the preferred way of writing `while true`:
556556

557557
~~~~
558-
# use std::int;
558+
use std::int;
559559
let mut x = 5;
560560
loop {
561561
x += x - 3;
@@ -701,7 +701,7 @@ get at their contents. All variant constructors can be used as
701701
patterns, as in this definition of `area`:
702702

703703
~~~~
704-
# use std::float;
704+
use std::float;
705705
# struct Point {x: float, y: float}
706706
# enum Shape { Circle(Point, float), Rectangle(Point, Point) }
707707
fn area(sh: Shape) -> float {
@@ -733,7 +733,7 @@ fn point_from_direction(dir: Direction) -> Point {
733733
Enum variants may also be structs. For example:
734734

735735
~~~~
736-
# use std::float;
736+
use std::float;
737737
# struct Point { x: float, y: float }
738738
# fn square(x: float) -> float { x * x }
739739
enum Shape {
@@ -1599,7 +1599,8 @@ lists back to back. Since that is so unsightly, empty argument lists
15991599
may be omitted from `do` expressions.
16001600

16011601
~~~~
1602-
# use std::task::spawn;
1602+
use std::task::spawn;
1603+
16031604
do spawn {
16041605
debug!("Kablam!");
16051606
}
@@ -1728,7 +1729,7 @@ impl Circle {
17281729
To call such a method, just prefix it with the type name and a double colon:
17291730

17301731
~~~~
1731-
# use std::float::consts::pi;
1732+
use std::float::consts::pi;
17321733
struct Circle { radius: float }
17331734
impl Circle {
17341735
fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }
@@ -1774,7 +1775,7 @@ illegal to copy and pass by value.
17741775
Generic `type`, `struct`, and `enum` declarations follow the same pattern:
17751776

17761777
~~~~
1777-
# use std::hashmap::HashMap;
1778+
use std::hashmap::HashMap;
17781779
type Set<T> = HashMap<T, ()>;
17791780
17801781
struct Stack<T> {
@@ -2000,7 +2001,7 @@ name and a double colon. The compiler uses type inference to decide which
20002001
implementation to use.
20012002

20022003
~~~~
2003-
# use std::float::consts::pi;
2004+
use std::float::consts::pi;
20042005
trait Shape { fn new(area: float) -> Self; }
20052006
struct Circle { radius: float }
20062007
struct Square { length: float }
@@ -2156,7 +2157,7 @@ trait Circle : Shape { fn radius(&self) -> float; }
21562157
Now, we can implement `Circle` on a type only if we also implement `Shape`.
21572158

21582159
~~~~
2159-
# use std::float::consts::pi;
2160+
use std::float::consts::pi;
21602161
# trait Shape { fn area(&self) -> float; }
21612162
# trait Circle : Shape { fn radius(&self) -> float; }
21622163
# struct Point { x: float, y: float }
@@ -2191,7 +2192,7 @@ fn radius_times_area<T: Circle>(c: T) -> float {
21912192
Likewise, supertrait methods may also be called on trait objects.
21922193

21932194
~~~ {.xfail-test}
2194-
# use std::float::consts::pi;
2195+
use std::float::consts::pi;
21952196
# trait Shape { fn area(&self) -> float; }
21962197
# trait Circle : Shape { fn radius(&self) -> float; }
21972198
# struct Point { x: float, y: float }

branches/auto/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
292292
}
293293
}
294294
if i != num_check_lines {
295-
fatal_ProcRes(fmt!("line not found in debugger output: %s"
295+
fatal_ProcRes(fmt!("line not found in debugger output: %s",
296296
check_lines[i]), &ProcRes);
297297
}
298298
}

branches/auto/src/etc/emacs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,8 @@ marking, press x, and ELPA will install the packages for you (under
9898
~/.emacs.d/elpa/).
9999

100100
* or using <kbd>M-x package-install rust-mode
101+
102+
### Known bugs
103+
104+
* Combining `global-whitespace-mode` and `rust-mode` is generally glitchy.
105+
See [Issue #3994](https://github.com/mozilla/rust/issues/3994).

branches/auto/src/libextra/base64.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'self> ToBase64 for &'self [u8] {
7575
*
7676
* fn main () {
7777
* let str = [52,32].to_base64(standard);
78-
* println(fmt!("%s", str));
78+
* printfln!("%s", str);
7979
* }
8080
* ~~~
8181
*/
@@ -164,7 +164,7 @@ impl<'self> ToBase64 for &'self str {
164164
*
165165
* fn main () {
166166
* let str = "Hello, World".to_base64(standard);
167-
* println(fmt!("%s",str));
167+
* printfln!("%s", str);
168168
* }
169169
* ~~~
170170
*
@@ -194,9 +194,9 @@ impl<'self> FromBase64 for &'self [u8] {
194194
*
195195
* fn main () {
196196
* let str = [52,32].to_base64(standard);
197-
* println(fmt!("%s", str));
197+
* printfln!("%s", str);
198198
* let bytes = str.from_base64();
199-
* println(fmt!("%?",bytes));
199+
* printfln!("%?", bytes);
200200
* }
201201
* ~~~
202202
*/
@@ -271,11 +271,11 @@ impl<'self> FromBase64 for &'self str {
271271
*
272272
* fn main () {
273273
* let hello_str = "Hello, World".to_base64(standard);
274-
* println(fmt!("%s",hello_str));
274+
* printfln!("%s", hello_str);
275275
* let bytes = hello_str.from_base64();
276-
* println(fmt!("%?",bytes));
276+
* printfln!("%?", bytes);
277277
* let result_str = str::from_bytes(bytes);
278-
* println(fmt!("%s",result_str));
278+
* printfln!("%s", result_str);
279279
* }
280280
* ~~~
281281
*/

branches/auto/src/libextra/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* # fn make_a_sandwich() {};
2020
* let mut delayed_fib = extra::future::spawn (|| fib(5000) );
2121
* make_a_sandwich();
22-
* println(fmt!("fib(5000) = %?", delayed_fib.get()))
22+
* printfln!("fib(5000) = %?", delayed_fib.get())
2323
* ~~~
2424
*/
2525

@@ -194,7 +194,7 @@ mod test {
194194
195195
#[test]
196196
fn test_interface_unwrap() {
197-
let f = from_value(~"fail");
197+
let mut f = from_value(~"fail");
198198
assert_eq!(f.unwrap(), ~"fail");
199199
}
200200

branches/auto/src/libextra/getopts.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* }
4545
*
4646
* fn print_usage(program: &str, _opts: &[Opt]) {
47-
* println(fmt!("Usage: %s [options]", program));
47+
* printfln!("Usage: %s [options]", program);
4848
* println("-o\t\tOutput");
4949
* println("-h --help\tUsage");
5050
* }
@@ -457,7 +457,7 @@ pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> {
457457
let vals = opt_vals(mm, nm);
458458
if vals.is_empty() { return None::<~str>; }
459459
return match vals[0] { Val(ref s) => Some::<~str>((*s).clone()),
460-
_ => Some::<~str>(def.to_owned()) }
460+
_ => Some::<~str>(str::to_owned(def)) }
461461
}
462462

463463
#[deriving(Eq)]
@@ -497,10 +497,10 @@ pub mod groups {
497497
desc: &str, hint: &str) -> OptGroup {
498498
let len = short_name.len();
499499
assert!(len == 1 || len == 0);
500-
return OptGroup { short_name: short_name.to_owned(),
501-
long_name: long_name.to_owned(),
502-
hint: hint.to_owned(),
503-
desc: desc.to_owned(),
500+
return OptGroup { short_name: str::to_owned(short_name),
501+
long_name: str::to_owned(long_name),
502+
hint: str::to_owned(hint),
503+
desc: str::to_owned(desc),
504504
hasarg: Yes,
505505
occur: Req};
506506
}
@@ -510,10 +510,10 @@ pub mod groups {
510510
desc: &str, hint: &str) -> OptGroup {
511511
let len = short_name.len();
512512
assert!(len == 1 || len == 0);
513-
return OptGroup {short_name: short_name.to_owned(),
514-
long_name: long_name.to_owned(),
515-
hint: hint.to_owned(),
516-
desc: desc.to_owned(),
513+
return OptGroup {short_name: str::to_owned(short_name),
514+
long_name: str::to_owned(long_name),
515+
hint: str::to_owned(hint),
516+
desc: str::to_owned(desc),
517517
hasarg: Yes,
518518
occur: Optional};
519519
}
@@ -523,10 +523,10 @@ pub mod groups {
523523
desc: &str) -> OptGroup {
524524
let len = short_name.len();
525525
assert!(len == 1 || len == 0);
526-
return OptGroup {short_name: short_name.to_owned(),
527-
long_name: long_name.to_owned(),
526+
return OptGroup {short_name: str::to_owned(short_name),
527+
long_name: str::to_owned(long_name),
528528
hint: ~"",
529-
desc: desc.to_owned(),
529+
desc: str::to_owned(desc),
530530
hasarg: No,
531531
occur: Optional};
532532
}
@@ -536,10 +536,10 @@ pub mod groups {
536536
desc: &str, hint: &str) -> OptGroup {
537537
let len = short_name.len();
538538
assert!(len == 1 || len == 0);
539-
return OptGroup {short_name: short_name.to_owned(),
540-
long_name: long_name.to_owned(),
541-
hint: hint.to_owned(),
542-
desc: desc.to_owned(),
539+
return OptGroup {short_name: str::to_owned(short_name),
540+
long_name: str::to_owned(long_name),
541+
hint: str::to_owned(hint),
542+
desc: str::to_owned(desc),
543543
hasarg: Maybe,
544544
occur: Optional};
545545
}
@@ -552,10 +552,10 @@ pub mod groups {
552552
desc: &str, hint: &str) -> OptGroup {
553553
let len = short_name.len();
554554
assert!(len == 1 || len == 0);
555-
return OptGroup {short_name: short_name.to_owned(),
556-
long_name: long_name.to_owned(),
557-
hint: hint.to_owned(),
558-
desc: desc.to_owned(),
555+
return OptGroup {short_name: str::to_owned(short_name),
556+
long_name: str::to_owned(long_name),
557+
hint: str::to_owned(hint),
558+
desc: str::to_owned(desc),
559559
hasarg: Yes,
560560
occur: Multi};
561561
}
@@ -678,7 +678,7 @@ pub mod groups {
678678
row
679679
});
680680

681-
return brief.to_owned() +
681+
return str::to_owned(brief) +
682682
"\n\nOptions:\n" +
683683
rows.collect::<~[~str]>().connect("\n") +
684684
"\n\n";

0 commit comments

Comments
 (0)