(core::str) removed [r]index_byte

This commit is contained in:
Kevin Cantu 2012-02-11 17:04:08 -08:00
parent e0af23b664
commit 207bb3d2df

View file

@ -72,8 +72,6 @@ export
// Searching
index,
rindex,
index_byte,
rindex_byte,
find,
contains,
starts_with,
@ -913,34 +911,6 @@ fn rindex(ss: str, cc: char) -> option<uint> {
ret option::none;
}
/*
Function: index
Returns the index of the first matching byte. Returns -1 if
no match is found.
FIXME: UTF-8
*/
fn index_byte(s: str, c: u8) -> int {
let i: int = 0;
for k: u8 in s { if k == c { ret i; } i += 1; }
ret -1;
}
/*
Function: rindex
Returns the index of the last matching byte. Returns -1
if no match is found.
FIXME: UTF-8
*/
fn rindex_byte(s: str, c: u8) -> int {
let n: int = byte_len(s) as int;
while n >= 0 { if s[n] == c { ret n; } n -= 1; }
ret n;
}
/*
Function: find
@ -1521,20 +1491,6 @@ mod tests {
assert (rindex("hello", 'z') == option::none);
}
#[test]
fn test_index_byte() {
assert ( index_byte("hello", 'e' as u8) == 1);
assert ( index_byte("hello", 'o' as u8) == 4);
assert ( index_byte("hello", 'z' as u8) == -1);
}
#[test]
fn test_rindex_byte() {
assert (rindex_byte("hello", 'l' as u8) == 3);
assert (rindex_byte("hello", 'h' as u8) == 0);
assert (rindex_byte("hello", 'z' as u8) == -1);
}
#[test]
fn test_pop_char() {
let data = "ประเทศไทย中华";