Skip to content

Commit 2b1b845

Browse files
committed
---
yaml --- r: 165517 b: refs/heads/master c: abf492d h: refs/heads/master i: 165515: cf17f30 v: v3
1 parent 359154e commit 2b1b845

File tree

218 files changed

+4273
-4878
lines changed

Some content is hidden

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

218 files changed

+4273
-4878
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: b04bc5cc49a398df712092a68ab9ad83019498ad
2+
refs/heads/master: abf492d44f0a3b705be8c0920bfb4771f039b843
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 658529467d9d69ac9e09cacf98a6d61d781c2c76
55
refs/heads/try: aee614fc4973262a5a68efc643026e2b1458d65b

trunk/src/compiletest/compiletest.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
152152
matches.opt_str("ratchet-metrics").map(|s| Path::new(s)),
153153
ratchet_noise_percent:
154154
matches.opt_str("ratchet-noise-percent")
155-
.and_then(|s| s.as_slice().parse::<f64>()),
155+
.and_then(|s| from_str::<f64>(s.as_slice())),
156156
runtool: matches.opt_str("runtool"),
157157
host_rustcflags: matches.opt_str("host-rustcflags"),
158158
target_rustcflags: matches.opt_str("target-rustcflags"),
@@ -190,7 +190,9 @@ pub fn log_config(config: &Config) {
190190
logv(c, format!("filter: {}",
191191
opt_str(&config.filter
192192
.as_ref()
193-
.map(|re| re.to_string()))));
193+
.map(|re| {
194+
re.to_string().into_string()
195+
}))));
194196
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
195197
logv(c, format!("host-rustcflags: {}",
196198
opt_str(&config.host_rustcflags)));

trunk/src/compiletest/header.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
351351
panic!("{}", error_string);
352352
}
353353

354-
let major: int = components[0].parse().expect(error_string);
355-
let minor: int = components[1].parse().expect(error_string);
354+
let major: int = from_str(components[0]).expect(error_string);
355+
let minor: int = from_str(components[1]).expect(error_string);
356356

357357
return major * 1000 + minor;
358358
}
@@ -362,6 +362,6 @@ pub fn lldb_version_to_int(version_string: &str) -> int {
362362
"Encountered LLDB version string with unexpected format: {}",
363363
version_string);
364364
let error_string = error_string.as_slice();
365-
let major: int = version_string.parse().expect(error_string);
365+
let major: int = from_str(version_string).expect(error_string);
366366
return major;
367367
}

trunk/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ fn split_maybe_args(argstr: &Option<String>) -> Vec<String> {
13611361
s.as_slice()
13621362
.split(' ')
13631363
.filter_map(|s| {
1364-
if s.chars().all(|c| c.is_whitespace()) {
1364+
if s.is_whitespace() {
13651365
None
13661366
} else {
13671367
Some(s.to_string())

trunk/src/doc/guide.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,10 +2257,10 @@ a function for that:
22572257
let input = io::stdin().read_line()
22582258
.ok()
22592259
.expect("Failed to read line");
2260-
let input_num: Option<uint> = input.parse();
2260+
let input_num: Option<uint> = from_str(input.as_slice());
22612261
```
22622262
2263-
The `parse` function takes in a `&str` value and converts it into something.
2263+
The `from_str` function takes in a `&str` value and converts it into something.
22642264
We tell it what kind of something with a type hint. Remember our type hint with
22652265
`random()`? It looked like this:
22662266
@@ -2279,8 +2279,8 @@ In this case, we say `x` is a `uint` explicitly, so Rust is able to properly
22792279
tell `random()` what to generate. In a similar fashion, both of these work:
22802280
22812281
```{rust,ignore}
2282-
let input_num = "5".parse::<uint>(); // input_num: Option<uint>
2283-
let input_num: Option<uint> = "5".parse(); // input_num: Option<uint>
2282+
let input_num = from_str::<uint>("5"); // input_num: Option<uint>
2283+
let input_num: Option<uint> = from_str("5"); // input_num: Option<uint>
22842284
```
22852285
22862286
Anyway, with us now converting our input to a number, our code looks like this:
@@ -2301,7 +2301,7 @@ fn main() {
23012301
let input = io::stdin().read_line()
23022302
.ok()
23032303
.expect("Failed to read line");
2304-
let input_num: Option<uint> = input.parse();
2304+
let input_num: Option<uint> = from_str(input.as_slice());
23052305

23062306
println!("You guessed: {}", input_num);
23072307

@@ -2350,7 +2350,7 @@ fn main() {
23502350
let input = io::stdin().read_line()
23512351
.ok()
23522352
.expect("Failed to read line");
2353-
let input_num: Option<uint> = input.parse();
2353+
let input_num: Option<uint> = from_str(input.as_slice());
23542354
23552355
let num = match input_num {
23562356
Some(num) => num,
@@ -2395,7 +2395,7 @@ Uh, what? But we did!
23952395
23962396
... actually, we didn't. See, when you get a line of input from `stdin()`,
23972397
you get all the input. Including the `\n` character from you pressing Enter.
2398-
Therefore, `parse()` sees the string `"5\n"` and says "nope, that's not a
2398+
Therefore, `from_str()` sees the string `"5\n"` and says "nope, that's not a
23992399
number; there's non-number stuff in there!" Luckily for us, `&str`s have an easy
24002400
method we can use defined on them: `trim()`. One small modification, and our
24012401
code looks like this:
@@ -2416,7 +2416,7 @@ fn main() {
24162416
let input = io::stdin().read_line()
24172417
.ok()
24182418
.expect("Failed to read line");
2419-
let input_num: Option<uint> = input.trim().parse();
2419+
let input_num: Option<uint> = from_str(input.as_slice().trim());
24202420
24212421
let num = match input_num {
24222422
Some(num) => num,
@@ -2491,7 +2491,7 @@ fn main() {
24912491
let input = io::stdin().read_line()
24922492
.ok()
24932493
.expect("Failed to read line");
2494-
let input_num: Option<uint> = input.trim().parse();
2494+
let input_num: Option<uint> = from_str(input.as_slice().trim());
24952495

24962496
let num = match input_num {
24972497
Some(num) => num,
@@ -2566,7 +2566,7 @@ fn main() {
25662566
let input = io::stdin().read_line()
25672567
.ok()
25682568
.expect("Failed to read line");
2569-
let input_num: Option<uint> = input.trim().parse();
2569+
let input_num: Option<uint> = from_str(input.as_slice().trim());
25702570
25712571
let num = match input_num {
25722572
Some(num) => num,
@@ -2621,7 +2621,7 @@ fn main() {
26212621
let input = io::stdin().read_line()
26222622
.ok()
26232623
.expect("Failed to read line");
2624-
let input_num: Option<uint> = input.trim().parse();
2624+
let input_num: Option<uint> = from_str(input.as_slice().trim());
26252625
26262626
let num = match input_num {
26272627
Some(num) => num,
@@ -2697,7 +2697,7 @@ fn main() {
26972697
let input = io::stdin().read_line()
26982698
.ok()
26992699
.expect("Failed to read line");
2700-
let input_num: Option<uint> = input.trim().parse();
2700+
let input_num: Option<uint> = from_str(input.as_slice().trim());
27012701
27022702
let num = match input_num {
27032703
Some(num) => num,

trunk/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3177,7 +3177,7 @@ Some examples of call expressions:
31773177
# fn add(x: int, y: int) -> int { 0 }
31783178
31793179
let x: int = add(1, 2);
3180-
let pi: Option<f32> = "3.14".parse();
3180+
let pi: Option<f32> = from_str("3.14");
31813181
```
31823182

31833183
### Lambda expressions

trunk/src/libcollections/binary_heap.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,16 @@ impl<T: Ord> BinaryHeap<T> {
272272
/// use std::collections::BinaryHeap;
273273
///
274274
/// let mut heap = BinaryHeap::new();
275-
/// assert_eq!(heap.top(), None);
275+
/// assert_eq!(heap.peek(), None);
276276
///
277277
/// heap.push(1i);
278278
/// heap.push(5i);
279279
/// heap.push(2i);
280-
/// assert_eq!(heap.top(), Some(&5i));
280+
/// assert_eq!(heap.peek(), Some(&5i));
281281
///
282282
/// ```
283-
pub fn top(&self) -> Option<&T> {
283+
#[stable]
284+
pub fn peek(&self) -> Option<&T> {
284285
self.data.get(0)
285286
}
286287

@@ -388,7 +389,7 @@ impl<T: Ord> BinaryHeap<T> {
388389
/// heap.push(1i);
389390
///
390391
/// assert_eq!(heap.len(), 3);
391-
/// assert_eq!(heap.top(), Some(&5i));
392+
/// assert_eq!(heap.peek(), Some(&5i));
392393
/// ```
393394
#[unstable = "matches collection reform specification, waiting for dust to settle"]
394395
pub fn push(&mut self, item: T) {
@@ -412,7 +413,7 @@ impl<T: Ord> BinaryHeap<T> {
412413
/// assert_eq!(heap.push_pop(3i), 5);
413414
/// assert_eq!(heap.push_pop(9i), 9);
414415
/// assert_eq!(heap.len(), 2);
415-
/// assert_eq!(heap.top(), Some(&3i));
416+
/// assert_eq!(heap.peek(), Some(&3i));
416417
/// ```
417418
pub fn push_pop(&mut self, mut item: T) -> T {
418419
match self.data.get_mut(0) {
@@ -442,7 +443,7 @@ impl<T: Ord> BinaryHeap<T> {
442443
/// assert_eq!(heap.replace(1i), None);
443444
/// assert_eq!(heap.replace(3i), Some(1i));
444445
/// assert_eq!(heap.len(), 1);
445-
/// assert_eq!(heap.top(), Some(&3i));
446+
/// assert_eq!(heap.peek(), Some(&3i));
446447
/// ```
447448
pub fn replace(&mut self, mut item: T) -> Option<T> {
448449
if !self.is_empty() {
@@ -714,13 +715,13 @@ mod tests {
714715
}
715716

716717
#[test]
717-
fn test_top_and_pop() {
718+
fn test_peek_and_pop() {
718719
let data = vec!(2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1);
719720
let mut sorted = data.clone();
720721
sorted.sort();
721722
let mut heap = BinaryHeap::from_vec(data);
722723
while !heap.is_empty() {
723-
assert_eq!(heap.top().unwrap(), sorted.last().unwrap());
724+
assert_eq!(heap.peek().unwrap(), sorted.last().unwrap());
724725
assert_eq!(heap.pop().unwrap(), sorted.pop().unwrap());
725726
}
726727
}
@@ -729,44 +730,44 @@ mod tests {
729730
fn test_push() {
730731
let mut heap = BinaryHeap::from_vec(vec!(2i, 4, 9));
731732
assert_eq!(heap.len(), 3);
732-
assert!(*heap.top().unwrap() == 9);
733+
assert!(*heap.peek().unwrap() == 9);
733734
heap.push(11);
734735
assert_eq!(heap.len(), 4);
735-
assert!(*heap.top().unwrap() == 11);
736+
assert!(*heap.peek().unwrap() == 11);
736737
heap.push(5);
737738
assert_eq!(heap.len(), 5);
738-
assert!(*heap.top().unwrap() == 11);
739+
assert!(*heap.peek().unwrap() == 11);
739740
heap.push(27);
740741
assert_eq!(heap.len(), 6);
741-
assert!(*heap.top().unwrap() == 27);
742+
assert!(*heap.peek().unwrap() == 27);
742743
heap.push(3);
743744
assert_eq!(heap.len(), 7);
744-
assert!(*heap.top().unwrap() == 27);
745+
assert!(*heap.peek().unwrap() == 27);
745746
heap.push(103);
746747
assert_eq!(heap.len(), 8);
747-
assert!(*heap.top().unwrap() == 103);
748+
assert!(*heap.peek().unwrap() == 103);
748749
}
749750

750751
#[test]
751752
fn test_push_unique() {
752753
let mut heap = BinaryHeap::from_vec(vec!(box 2i, box 4, box 9));
753754
assert_eq!(heap.len(), 3);
754-
assert!(*heap.top().unwrap() == box 9);
755+
assert!(*heap.peek().unwrap() == box 9);
755756
heap.push(box 11);
756757
assert_eq!(heap.len(), 4);
757-
assert!(*heap.top().unwrap() == box 11);
758+
assert!(*heap.peek().unwrap() == box 11);
758759
heap.push(box 5);
759760
assert_eq!(heap.len(), 5);
760-
assert!(*heap.top().unwrap() == box 11);
761+
assert!(*heap.peek().unwrap() == box 11);
761762
heap.push(box 27);
762763
assert_eq!(heap.len(), 6);
763-
assert!(*heap.top().unwrap() == box 27);
764+
assert!(*heap.peek().unwrap() == box 27);
764765
heap.push(box 3);
765766
assert_eq!(heap.len(), 7);
766-
assert!(*heap.top().unwrap() == box 27);
767+
assert!(*heap.peek().unwrap() == box 27);
767768
heap.push(box 103);
768769
assert_eq!(heap.len(), 8);
769-
assert!(*heap.top().unwrap() == box 103);
770+
assert!(*heap.peek().unwrap() == box 103);
770771
}
771772

772773
#[test]
@@ -831,9 +832,9 @@ mod tests {
831832
}
832833

833834
#[test]
834-
fn test_empty_top() {
835+
fn test_empty_peek() {
835836
let empty = BinaryHeap::<int>::new();
836-
assert!(empty.top().is_none());
837+
assert!(empty.peek().is_none());
837838
}
838839

839840
#[test]

0 commit comments

Comments
 (0)