1
Fork 0

(core::str) rename index -> index_chars

This commit is contained in:
Kevin Cantu 2012-02-21 21:38:40 -08:00 committed by Marijn Haverbeke
parent 8ea96169ff
commit 969fdf419c
3 changed files with 10 additions and 12 deletions

View file

@ -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));

View file

@ -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)
}

View file

@ -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<uint> {
fn index_chars(ss: str, cc: char) -> option<uint> {
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]