Skip to content

Commit 838191c

Browse files
committed
std: replace str::{starts,ends}_with with the method.
1 parent 248b6e3 commit 838191c

File tree

12 files changed

+40
-66
lines changed

12 files changed

+40
-66
lines changed

src/compiletest/compiletest.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
231231
let mut valid = false;
232232

233233
for valid_extensions.each |ext| {
234-
if str::ends_with(name, *ext) { valid = true; }
234+
if name.ends_with(*ext) { valid = true; }
235235
}
236236

237237
for invalid_prefixes.each |pre| {
238-
if str::starts_with(name, *pre) { valid = false; }
238+
if name.starts_with(*pre) { valid = false; }
239239
}
240240

241241
return valid;

src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool {
112112
// Assume that any directives will be found before the first
113113
// module or function. This doesn't seem to be an optimization
114114
// with a warm page cache. Maybe with a cold one.
115-
if str::starts_with(ln, "fn") || str::starts_with(ln, "mod") {
115+
if ln.starts_with("fn") || ln.starts_with("mod") {
116116
return false;
117117
} else { if !(it(ln)) { return false; } }
118118
}

src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
2828
if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
2929
else { (k,v) }
3030
};
31-
if str::ends_with(prog, "rustc.exe") {
31+
if prog.ends_with("rustc.exe") {
3232
env.push((~"RUST_THREADS", ~"1"));
3333
}
3434
return env;

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
364364
if !found_flags[i] {
365365
debug!("prefix=%s ee.kind=%s ee.msg=%s line=%s",
366366
prefixes[i], ee.kind, ee.msg, line);
367-
if (str::starts_with(line, prefixes[i]) &&
367+
if (line.starts_with(prefixes[i]) &&
368368
line.contains(ee.kind) &&
369369
line.contains(ee.msg)) {
370370
found_flags[i] = true;

src/libextra/net_url.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ enum Input {
394394
// returns userinfo, host, port, and unparsed part, or an error
395395
fn get_authority(rawurl: &str) ->
396396
Result<(Option<UserInfo>, ~str, Option<~str>, ~str), ~str> {
397-
if !str::starts_with(rawurl, "//") {
397+
if !raw_url.starts_with("//") {
398398
// there is no authority.
399399
return Ok((None, ~"", None, rawurl.to_str()));
400400
}
@@ -579,7 +579,7 @@ fn get_path(rawurl: &str, authority: bool) ->
579579
}
580580

581581
if authority {
582-
if end != 0 && !str::starts_with(rawurl, "/") {
582+
if end != 0 && !rawurl.starts_with("/") {
583583
return Err(~"Non-empty path must begin with\
584584
'/' in presence of authority.");
585585
}
@@ -592,8 +592,8 @@ fn get_path(rawurl: &str, authority: bool) ->
592592
// returns the parsed query and the fragment, if present
593593
fn get_query_fragment(rawurl: &str) ->
594594
Result<(Query, Option<~str>), ~str> {
595-
if !str::starts_with(rawurl, "?") {
596-
if str::starts_with(rawurl, "#") {
595+
if !rawurl.starts_with("?") {
596+
if rawurl.starts_with("#") {
597597
let f = decode_component(rawurl.slice(
598598
1,
599599
rawurl.len()));

src/libextra/tempfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mod tests {
4242
fn test_mkdtemp() {
4343
let p = mkdtemp(&Path("."), "foobar").unwrap();
4444
os::remove_dir(&p);
45-
assert!(str::ends_with(p.to_str(), "foobar"));
45+
assert!(p.to_str().ends_with("foobar"));
4646
}
4747

4848
// Ideally these would be in core::os but then core would need

src/librustc/back/rpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ mod test {
240240
debug!("test_prefix_path: %s vs. %s",
241241
res.to_str(),
242242
d.to_str());
243-
assert!(str::ends_with(res.to_str(), d.to_str()));
243+
assert!(res.to_str().ends_with(d.to_str()));
244244
}
245245
246246
#[test]

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ fn get_cache(cx: @CrateContext) -> metadata_cache {
244244
}
245245

246246
fn get_file_path_and_dir(work_dir: &str, full_path: &str) -> (~str, ~str) {
247-
(if str::starts_with(full_path, work_dir) {
247+
(if full_path.starts_with(work_dir) {
248248
full_path.slice(work_dir.len() + 1u,
249249
full_path.len()).to_owned()
250250
} else {

src/librustdoc/desc_to_brief_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn first_sentence_(s: &str) -> ~str {
134134
str::to_owned(s.slice(0, idx - 1))
135135
}
136136
_ => {
137-
if str::ends_with(s, ".") {
137+
if s.ends_with(".") {
138138
str::to_owned(s)
139139
} else {
140140
str::to_owned(s)

src/librustdoc/sectionalize_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
153153
}
154154

155155
fn parse_header(line: ~str) -> Option<~str> {
156-
if str::starts_with(line, "# ") {
156+
if line.starts_with("# ") {
157157
Some(line.slice(2u, line.len()).to_owned())
158158
} else {
159159
None

0 commit comments

Comments
 (0)