(core::str) rename rindex -> rindex_chars
This commit is contained in:
parent
969fdf419c
commit
1cd5a0945a
3 changed files with 11 additions and 11 deletions
|
@ -286,7 +286,7 @@ fn check_variants_T<T: copy>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last_part(filename: str) -> str {
|
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)
|
str::slice(filename, ix + 1u, str::len_chars(filename) - 3u)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ export
|
||||||
index_chars,
|
index_chars,
|
||||||
byte_index,
|
byte_index,
|
||||||
byte_index_from,
|
byte_index_from,
|
||||||
rindex,
|
rindex_chars,
|
||||||
find,
|
find,
|
||||||
find_bytes,
|
find_bytes,
|
||||||
find_from_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 } }
|
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
|
// Returns the index of the first matching char
|
||||||
// (as option some/none)
|
// (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 bii = len_bytes(ss);
|
||||||
let cii = len_chars(ss);
|
let cii = len_chars(ss);
|
||||||
while bii > 0u {
|
while bii > 0u {
|
||||||
|
@ -1546,11 +1546,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rindex() {
|
fn test_rindex_chars() {
|
||||||
assert (rindex("hello", 'l') == some(3u));
|
assert (rindex_chars("hello", 'l') == some(3u));
|
||||||
assert (rindex("hello", 'o') == some(4u));
|
assert (rindex_chars("hello", 'o') == some(4u));
|
||||||
assert (rindex("hello", 'h') == some(0u));
|
assert (rindex_chars("hello", 'h') == some(0u));
|
||||||
assert (rindex("hello", 'z') == none);
|
assert (rindex_chars("hello", 'z') == none);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -34,10 +34,10 @@ type path = str;
|
||||||
|
|
||||||
fn splitDirnameBasename (pp: path) -> {dirname: str, basename: str} {
|
fn splitDirnameBasename (pp: path) -> {dirname: str, basename: str} {
|
||||||
let ii;
|
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::some(xx) { ii = xx; }
|
||||||
option::none {
|
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::some(xx) { ii = xx; }
|
||||||
option::none { ret {dirname: ".", basename: pp}; }
|
option::none { ret {dirname: ".", basename: pp}; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue