diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-07-31 12:54:49 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-07-31 12:54:49 -0600 |
commit | a54404c92180b839d2cf089d9ec9a6afe8bd5ba3 (patch) | |
tree | 08fb013f6d9e437e15893796068f8d8e06bf1a91 /components/script/textinput.rs | |
parent | 7e772857458f60a68346ac1a7020ae51d65959a1 (diff) | |
parent | dae1a398a43b92aa7390379417e00c7fddb14762 (diff) | |
download | servo-a54404c92180b839d2cf089d9ec9a6afe8bd5ba3.tar.gz servo-a54404c92180b839d2cf089d9ec9a6afe8bd5ba3.zip |
Auto merge of #6876 - metajack:slice_chars-layout, r=pcwalton
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.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6876)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r-- | components/script/textinput.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 9ce3a482a65..a88f2bf491a 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -8,7 +8,7 @@ use clipboard_provider::ClipboardProvider; use dom::keyboardevent::{KeyboardEvent, KeyboardEventHelpers, key_value}; use msg::constellation_msg::{SHIFT, CONTROL, ALT, SUPER}; use msg::constellation_msg::{Key, KeyModifiers}; -use util::str::DOMString; +use util::str::{DOMString, slice_chars}; use std::borrow::ToOwned; use std::cmp::{min, max}; @@ -159,16 +159,16 @@ impl<T: ClipboardProvider> TextInput<T> { self.get_sorted_selection().map(|(begin, end)| { if begin.line != end.line { let mut s = String::new(); - s.push_str(self.lines[begin.line].slice_chars(begin.index, self.lines[begin.line].len())); + s.push_str(slice_chars(&self.lines[begin.line], begin.index, self.lines[begin.line].len())); for (_, line) in self.lines.iter().enumerate().filter(|&(i,_)| begin.line < i && i < end.line) { s.push_str("\n"); s.push_str(line); } s.push_str("\n"); - s.push_str(self.lines[end.line].slice_chars(0, end.index)); + s.push_str(slice_chars(&self.lines[end.line], 0, end.index)); s } else { - self.lines[begin.line].slice_chars(begin.index, end.index).to_owned() + slice_chars(&self.lines[begin.line], begin.index, end.index).to_owned() } }) } @@ -178,8 +178,8 @@ impl<T: ClipboardProvider> TextInput<T> { self.clear_selection(); let new_lines = { - 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].chars().count()); + let prefix = slice_chars(&self.lines[begin.line], 0, begin.index); + let suffix = slice_chars(&self.lines[end.line], end.index, self.lines[end.line].chars().count()); let lines_prefix = &self.lines[..begin.line]; let lines_suffix = &self.lines[end.line + 1..]; |