Skip to content

Commit 248b6e3

Browse files
committed
std: replace str::substr with the method.
1 parent ebefe42 commit 248b6e3

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

src/libextra/rope.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ pub fn of_str(str: @~str) -> Rope {
8383
*
8484
* # Return value
8585
*
86-
* A rope representing the same string as `str::substr(str, byte_offset,
87-
* byte_len)`. Depending on `byte_len`, this rope may be empty, flat or
88-
* complex.
86+
* A rope representing the same string as `str.substr(byte_offset,
87+
* byte_len)`. Depending on `byte_len`, this rope may be empty, flat
88+
* or complex.
8989
*
9090
* # Performance note
9191
*

src/librustc/middle/resolve.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,11 +2684,11 @@ impl Resolver {
26842684
match self.idents_to_str(module_path).rfind(':') {
26852685
Some(idx) => {
26862686
self.session.span_err(span, fmt!("unresolved import: could not find `%s` \
2687-
in `%s`", str::substr(mpath, idx,
2688-
mpath.len() - idx),
2687+
in `%s`", mpath.substr(idx,
2688+
mpath.len() - idx),
26892689
// idx - 1 to account for the extra
26902690
// colon
2691-
str::substr(mpath, 0, idx - 1)));
2691+
mpath.substr(0, idx - 1)));
26922692
},
26932693
None => (),
26942694
};

src/libstd/str.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -432,16 +432,6 @@ pub fn byte_slice_no_callback<'a>(s: &'a str) -> &'a [u8] {
432432
}
433433
}
434434

435-
/**
436-
* Take a substring of another.
437-
*
438-
* Returns a slice pointing at `n` characters starting from byte offset
439-
* `begin`.
440-
*/
441-
pub fn substr<'a>(s: &'a str, begin: uint, n: uint) -> &'a str {
442-
s.slice(begin, begin + count_bytes(s, begin, n))
443-
}
444-
445435
/// Something that can be used to compare against a character
446436
pub trait CharEq {
447437
/// Determine if the splitter should split at the given character
@@ -1854,7 +1844,7 @@ impl<'self> StrSlice<'self> for &'self str {
18541844
*/
18551845
#[inline]
18561846
fn substr(&self, begin: uint, n: uint) -> &'self str {
1857-
substr(*self, begin, n)
1847+
s.slice(begin, begin + count_bytes(s, begin, n))
18581848
}
18591849
/// Escape each char in `s` with char::escape_default.
18601850
#[inline]
@@ -2516,11 +2506,11 @@ mod tests {
25162506
#[test]
25172507
fn test_substr() {
25182508
fn t(a: &str, b: &str, start: int) {
2519-
assert_eq!(substr(a, start as uint, b.len()), b);
2509+
assert_eq!(a.substr(start as uint, b.len()), b);
25202510
}
25212511
t("hello", "llo", 2);
25222512
t("hello", "el", 1);
2523-
assert_eq!("ะเทศไท", substr("ประเทศไทย中华Việt Nam", 6u, 6u));
2513+
assert_eq!("ะเทศไท", "ประเทศไทย中华Việt Nam".substr(6u, 6u));
25242514
}
25252515
25262516
#[test]

0 commit comments

Comments
 (0)