Skip to content

Commit 082bfde

Browse files
committed
Fallout of std::str stabilization
1 parent 4908017 commit 082bfde

File tree

193 files changed

+2142
-2229
lines changed

Some content is hidden

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

193 files changed

+2142
-2229
lines changed

Diff for: src/compiletest/compiletest.rs

+2-4
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| from_str::<f64>(s.as_slice())),
155+
.and_then(|s| s.as_slice().parse::<f64>()),
156156
runtool: matches.opt_str("runtool"),
157157
host_rustcflags: matches.opt_str("host-rustcflags"),
158158
target_rustcflags: matches.opt_str("target-rustcflags"),
@@ -190,9 +190,7 @@ pub fn log_config(config: &Config) {
190190
logv(c, format!("filter: {}",
191191
opt_str(&config.filter
192192
.as_ref()
193-
.map(|re| {
194-
re.to_string().into_string()
195-
}))));
193+
.map(|re| re.to_string()))));
196194
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
197195
logv(c, format!("host-rustcflags: {}",
198196
opt_str(&config.host_rustcflags)));

Diff for: src/compiletest/header.rs

+3-3
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 = from_str(components[0]).expect(error_string);
355-
let minor: int = from_str(components[1]).expect(error_string);
354+
let major: int = components[0].parse().expect(error_string);
355+
let minor: int = components[1].parse().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 = from_str(version_string).expect(error_string);
365+
let major: int = version_string.parse().expect(error_string);
366366
return major;
367367
}

Diff for: src/compiletest/runtest.rs

+1-1
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.is_whitespace() {
1364+
if s.chars().all(|c| c.is_whitespace()) {
13651365
None
13661366
} else {
13671367
Some(s.to_string())

Diff for: src/doc/guide.md

+12-12
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> = from_str(input.as_slice());
2260+
let input_num: Option<uint> = input.parse();
22612261
```
22622262
2263-
The `from_str` function takes in a `&str` value and converts it into something.
2263+
The `parse` 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 = from_str::<uint>("5"); // input_num: Option<uint>
2283-
let input_num: Option<uint> = from_str("5"); // input_num: Option<uint>
2282+
let input_num = "5".parse::<uint>(); // input_num: Option<uint>
2283+
let input_num: Option<uint> = "5".parse(); // 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> = from_str(input.as_slice());
2304+
let input_num: Option<uint> = input.parse();
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> = from_str(input.as_slice());
2353+
let input_num: Option<uint> = input.parse();
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, `from_str()` sees the string `"5\n"` and says "nope, that's not a
2398+
Therefore, `parse()` 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> = from_str(input.as_slice().trim());
2419+
let input_num: Option<uint> = input.trim().parse();
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> = from_str(input.as_slice().trim());
2494+
let input_num: Option<uint> = input.trim().parse();
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> = from_str(input.as_slice().trim());
2569+
let input_num: Option<uint> = input.trim().parse();
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> = from_str(input.as_slice().trim());
2624+
let input_num: Option<uint> = input.trim().parse();
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> = from_str(input.as_slice().trim());
2700+
let input_num: Option<uint> = input.trim().parse();
27012701
27022702
let num = match input_num {
27032703
Some(num) => num,

Diff for: src/doc/reference.md

+1-1
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> = from_str("3.14");
3180+
let pi: Option<f32> = "3.14".parse();
31813181
```
31823182

31833183
### Lambda expressions

Diff for: src/libcollections/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ mod prelude {
121121
// in core and collections (may differ).
122122
pub use slice::{PartialEqSliceExt, OrdSliceExt};
123123
pub use slice::{AsSlice, SliceExt};
124-
pub use str::{from_str, Str, StrPrelude};
124+
pub use str::{from_str, Str};
125125

126126
// from other crates.
127127
pub use alloc::boxed::Box;
128128
pub use unicode::char::UnicodeChar;
129129

130130
// from collections.
131131
pub use slice::{CloneSliceExt, VectorVector};
132-
pub use str::{IntoMaybeOwned, UnicodeStrPrelude, StrAllocating, StrVector};
132+
pub use str::{IntoMaybeOwned, StrVector};
133133
pub use string::{String, ToString};
134134
pub use vec::Vec;
135135
}

0 commit comments

Comments
 (0)