mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
(core::str) rename substr_len_bytes to substr_len, and delete unused byte_index[_from]
This commit is contained in:
parent
7782f5d692
commit
c3318f29fe
@ -171,7 +171,7 @@ fn lookup_byte_offset(cm: codemap::codemap, chpos: uint)
|
||||
let {fm,line} = lookup_line(cm,chpos,lookup);
|
||||
let line_offset = fm.lines[line].byte - fm.start_pos.byte;
|
||||
let col = chpos - fm.lines[line].ch;
|
||||
let col_offset = str::substr_len_bytes(*fm.src, line_offset, col);
|
||||
let col_offset = str::substr_len(*fm.src, line_offset, col);
|
||||
ret {fm: fm, pos: line_offset + col_offset};
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ export
|
||||
// Misc
|
||||
// FIXME: perhaps some more of this section shouldn't be exported?
|
||||
is_utf8,
|
||||
substr_len_bytes,
|
||||
substr_len,
|
||||
substr_len_chars,
|
||||
utf8_char_width,
|
||||
char_range_at,
|
||||
@ -914,27 +914,6 @@ fn index_chars(ss: str, cc: char) -> option<uint> {
|
||||
ret none;
|
||||
}
|
||||
|
||||
// Function: byte_index
|
||||
//
|
||||
// Returns the index of the first matching byte
|
||||
// (as option some/none)
|
||||
// FIXME: delete
|
||||
fn byte_index(s: str, b: u8) -> option<uint> {
|
||||
byte_index_from(s, b, 0u, len(s))
|
||||
}
|
||||
|
||||
// Function: byte_index_from
|
||||
//
|
||||
// Returns the index of the first matching byte within the range [`start`,
|
||||
// `end`).
|
||||
// (as option some/none)
|
||||
// FIXME: delete
|
||||
fn byte_index_from(s: str, b: u8, start: uint, end: uint) -> option<uint> {
|
||||
assert end <= len(s);
|
||||
|
||||
str::as_bytes(s) { |v| vec::position_from(v, start, end) { |x| x == b } }
|
||||
}
|
||||
|
||||
// Function: rindex
|
||||
//
|
||||
// Returns the byte index of the first matching char
|
||||
|
@ -795,7 +795,7 @@ mod node {
|
||||
if i == 0u { first_leaf_char_len }
|
||||
else { hint_max_leaf_char_len };
|
||||
let chunk_byte_len =
|
||||
str::substr_len_bytes(*str, offset, chunk_char_len);
|
||||
str::substr_len(*str, offset, chunk_char_len);
|
||||
nodes[i] = @leaf({
|
||||
byte_offset: offset,
|
||||
byte_len: chunk_byte_len,
|
||||
@ -1059,9 +1059,9 @@ mod node {
|
||||
ret node;
|
||||
}
|
||||
let byte_offset =
|
||||
str::substr_len_bytes(*x.content, 0u, char_offset);
|
||||
str::substr_len(*x.content, 0u, char_offset);
|
||||
let byte_len =
|
||||
str::substr_len_bytes(*x.content, byte_offset, char_len);
|
||||
str::substr_len(*x.content, byte_offset, char_len);
|
||||
ret @leaf({byte_offset: byte_offset,
|
||||
byte_len: byte_len,
|
||||
char_len: char_len,
|
||||
|
Loading…
Reference in New Issue
Block a user