Use local slice_chars

StrExt::slice_chars is deprecated and will be removed in Rust. This
lifts the implementation from Rust libstd and puts it in util::str.

This fixes a bunch of deprecation warnings in Servo.
This commit is contained in:
Jack Moffitt 2015-07-31 12:23:13 -06:00
parent ca9f9226b0
commit dae1a398a4
7 changed files with 41 additions and 17 deletions

View file

@ -35,6 +35,7 @@ use unicode_bidi;
use util::geometry::{Au, MAX_AU, ZERO_RECT};
use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use util::range::{Range, RangeIndex};
use util::str::slice_chars;
use util;
// From gfxFontConstants.h in Firefox
@ -1801,7 +1802,7 @@ fn strip_trailing_whitespace_if_necessary(text_run: &TextRun, range: &mut Range<
debug!("stripping trailing whitespace: range={:?}, len={}",
range,
text_run.text.chars().count());
let text = text_run.text.slice_chars(range.begin().to_usize(), range.end().to_usize());
let text = slice_chars(&*text_run.text, range.begin().to_usize(), range.end().to_usize());
let mut trailing_whitespace_character_count = 0;
for ch in text.chars().rev() {
if util::str::char_is_whitespace(ch) {