From 969fdf419ca90c38b628de2693d00b3589d7a907 Mon Sep 17 00:00:00 2001 From: Kevin Cantu Date: Tue, 21 Feb 2012 21:38:40 -0800 Subject: [PATCH] (core::str) rename index -> index_chars --- src/cargo/cargo.rs | 4 ++-- src/comp/back/link.rs | 2 +- src/libcore/str.rs | 16 +++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 8e8996551fa5..bce9bb5f84fa 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -686,7 +686,7 @@ fn cmd_install(c: cargo) unsafe { if str::starts_with(target, "uuid:") { let uuid = rest(target, 5u); - alt str::index(uuid, '/') { + alt str::index_chars(uuid, '/') { option::some(idx) { let source = str::slice(uuid, 0u, idx); uuid = str::slice(uuid, idx + 1u, str::len_chars(uuid)); @@ -698,7 +698,7 @@ fn cmd_install(c: cargo) unsafe { } } else { let name = target; - alt str::index(name, '/') { + alt str::index_chars(name, '/') { option::some(idx) { let source = str::slice(name, 0u, idx); name = str::slice(name, idx + 1u, str::len_chars(name)); diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 5b7d7a35c537..ee450814ef96 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -109,7 +109,7 @@ mod write { // Decides what to call an intermediate file, given the name of the output // and the extension to use. fn mk_intermediate_name(output_path: str, extension: str) -> str unsafe { - let stem = alt str::index(output_path, '.') { + let stem = alt str::index_chars(output_path, '.') { option::some(dot_pos) { str::slice(output_path, 0u, dot_pos) } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index c8f7706977a1..3c8cd7a3b853 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -69,7 +69,7 @@ export lines_iter, // Searching - index, + index_chars, byte_index, byte_index_from, rindex, @@ -838,7 +838,7 @@ Section: Searching // // Returns the index of the first matching char // (as option some/none) -fn index(ss: str, cc: char) -> option { +fn index_chars(ss: str, cc: char) -> option { let bii = 0u; let cii = 0u; let len = len_bytes(ss); @@ -1157,8 +1157,6 @@ Safety note: This function fails if `byte_offset` or `char_len` do not represent valid positions in `s` - -FIXME: rename to 'substr_len_bytes' */ fn substr_len_bytes(s: str, byte_offset: uint, char_len: uint) -> uint { let i = byte_offset; @@ -1540,11 +1538,11 @@ mod tests { } #[test] - fn test_index() { - assert ( index("hello", 'h') == some(0u)); - assert ( index("hello", 'e') == some(1u)); - assert ( index("hello", 'o') == some(4u)); - assert ( index("hello", 'z') == none); + fn test_index_chars() { + assert ( index_chars("hello", 'h') == some(0u)); + assert ( index_chars("hello", 'e') == some(1u)); + assert ( index_chars("hello", 'o') == some(4u)); + assert ( index_chars("hello", 'z') == none); } #[test]