(core::str) rename rindex -> rindex_chars

This commit is contained in:
Kevin Cantu 2012-02-21 21:48:03 -08:00 committed by Marijn Haverbeke
parent 969fdf419c
commit 1cd5a0945a
3 changed files with 11 additions and 11 deletions

View File

@ -286,7 +286,7 @@ fn check_variants_T<T: copy>(
}
fn last_part(filename: str) -> str {
let ix = option::get(str::rindex(filename, '/'));
let ix = option::get(str::rindex_chars(filename, '/'));
str::slice(filename, ix + 1u, str::len_chars(filename) - 3u)
}

View File

@ -72,7 +72,7 @@ export
index_chars,
byte_index,
byte_index_from,
rindex,
rindex_chars,
find,
find_bytes,
find_from_bytes,
@ -877,11 +877,11 @@ fn byte_index_from(s: str, b: u8, start: uint, end: uint) -> option<uint> {
str::as_bytes(s) { |v| vec::position_from(v, start, end) { |x| x == b } }
}
// Function: rindex
// Function: rindex_chars
//
// Returns the index of the first matching char
// (as option some/none)
fn rindex(ss: str, cc: char) -> option<uint> {
fn rindex_chars(ss: str, cc: char) -> option<uint> {
let bii = len_bytes(ss);
let cii = len_chars(ss);
while bii > 0u {
@ -1546,11 +1546,11 @@ mod tests {
}
#[test]
fn test_rindex() {
assert (rindex("hello", 'l') == some(3u));
assert (rindex("hello", 'o') == some(4u));
assert (rindex("hello", 'h') == some(0u));
assert (rindex("hello", 'z') == none);
fn test_rindex_chars() {
assert (rindex_chars("hello", 'l') == some(3u));
assert (rindex_chars("hello", 'o') == some(4u));
assert (rindex_chars("hello", 'h') == some(0u));
assert (rindex_chars("hello", 'z') == none);
}
#[test]

View File

@ -34,10 +34,10 @@ type path = str;
fn splitDirnameBasename (pp: path) -> {dirname: str, basename: str} {
let ii;
alt str::rindex(pp, os_fs::path_sep) {
alt str::rindex_chars(pp, os_fs::path_sep) {
option::some(xx) { ii = xx; }
option::none {
alt str::rindex(pp, os_fs::alt_path_sep) {
alt str::rindex_chars(pp, os_fs::alt_path_sep) {
option::some(xx) { ii = xx; }
option::none { ret {dirname: ".", basename: pp}; }
}