Use chars().count() rather than char_len().

The latter is obsolete in current Rust.
This commit is contained in:
Ms2ger 2015-01-22 13:49:10 +01:00
parent faefb27f3e
commit 024571dfa3
5 changed files with 9 additions and 9 deletions

View file

@ -157,7 +157,7 @@ impl Font {
Some(glyphs) => return (*glyphs).clone(), Some(glyphs) => return (*glyphs).clone(),
} }
let mut glyphs = GlyphStore::new(text.char_len() as int, let mut glyphs = GlyphStore::new(text.chars().count() as int,
options.flags.contains(IS_WHITESPACE_SHAPING_FLAG)); options.flags.contains(IS_WHITESPACE_SHAPING_FLAG));
shaper.as_ref().unwrap().shape_text(text, options, &mut glyphs); shaper.as_ref().unwrap().shape_text(text, options, &mut glyphs);

View file

@ -274,7 +274,7 @@ impl Shaper {
let glyph_data = ShapedGlyphData::new(buffer); let glyph_data = ShapedGlyphData::new(buffer);
let glyph_count = glyph_data.len(); let glyph_count = glyph_data.len();
let byte_max = text.len() as int; let byte_max = text.len() as int;
let char_max = text.char_len() as int; let char_max = text.chars().count() as int;
// GlyphStore records are indexed by character, not byte offset. // GlyphStore records are indexed by character, not byte offset.
// so, we must be careful to increment this when saving glyph entries. // so, we must be careful to increment this when saving glyph entries.

View file

@ -138,7 +138,7 @@ impl TextRunScanner {
}; };
let mut new_line_pos = Vec::new(); let mut new_line_pos = Vec::new();
let old_length = CharIndex(run_text.as_slice().char_len() as int); let old_length = CharIndex(run_text.chars().count() as int);
last_whitespace = util::transform_text(in_fragment.as_slice(), last_whitespace = util::transform_text(in_fragment.as_slice(),
compression, compression,
last_whitespace, last_whitespace,
@ -146,7 +146,7 @@ impl TextRunScanner {
&mut new_line_pos); &mut new_line_pos);
new_line_positions.push(NewLinePositions(new_line_pos)); new_line_positions.push(NewLinePositions(new_line_pos));
let added_chars = CharIndex(run_text.as_slice().char_len() as int) - old_length; let added_chars = CharIndex(run_text.chars().count() as int) - old_length;
new_ranges.push(Range::new(char_total, added_chars)); new_ranges.push(Range::new(char_total, added_chars));
char_total = char_total + added_chars; char_total = char_total + added_chars;
} }

View file

@ -161,7 +161,7 @@ impl LayoutHTMLInputElementHelpers for JS<HTMLInputElement> {
InputType::InputReset => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_RESET_VALUE.to_owned()), InputType::InputReset => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_RESET_VALUE.to_owned()),
InputType::InputPassword => { InputType::InputPassword => {
let raw = get_raw_textinput_value(self); let raw = get_raw_textinput_value(self);
String::from_char(raw.char_len(), '●') raw.chars().map(|_| '●').collect()
} }
_ => get_raw_textinput_value(self), _ => get_raw_textinput_value(self),
} }

View file

@ -135,7 +135,7 @@ impl TextInput {
let new_lines = { let new_lines = {
let prefix = self.lines[begin.line].slice_chars(0, begin.index); let prefix = self.lines[begin.line].slice_chars(0, begin.index);
let suffix = self.lines[end.line].slice_chars(end.index, self.lines[end.line].char_len()); let suffix = self.lines[end.line].slice_chars(end.index, self.lines[end.line].chars().count());
let lines_prefix = self.lines.slice(0, begin.line); let lines_prefix = self.lines.slice(0, begin.line);
let lines_suffix = self.lines.slice(end.line + 1, self.lines.len()); let lines_suffix = self.lines.slice(end.line + 1, self.lines.len());
@ -150,7 +150,7 @@ impl TextInput {
insert_lines[0] = new_line; insert_lines[0] = new_line;
let last_insert_lines_index = insert_lines.len() - 1; let last_insert_lines_index = insert_lines.len() - 1;
self.edit_point.index = insert_lines[last_insert_lines_index].char_len(); self.edit_point.index = insert_lines[last_insert_lines_index].chars().count();
self.edit_point.line = begin.line + last_insert_lines_index; self.edit_point.line = begin.line + last_insert_lines_index;
insert_lines[last_insert_lines_index].push_str(suffix); insert_lines[last_insert_lines_index].push_str(suffix);
@ -167,7 +167,7 @@ impl TextInput {
/// Return the length of the current line under the editing point. /// Return the length of the current line under the editing point.
fn current_line_length(&self) -> uint { fn current_line_length(&self) -> uint {
self.lines[self.edit_point.line].char_len() self.lines[self.edit_point.line].chars().count()
} }
/// Adjust the editing point position by a given of lines. The resulting column is /// Adjust the editing point position by a given of lines. The resulting column is
@ -260,7 +260,7 @@ impl TextInput {
}); });
let last_line = self.lines.len() - 1; let last_line = self.lines.len() - 1;
self.edit_point.line = last_line; self.edit_point.line = last_line;
self.edit_point.index = self.lines[last_line].char_len(); self.edit_point.index = self.lines[last_line].chars().count();
} }
/// Remove the current selection. /// Remove the current selection.