Move to to_owned rather than into_string.

into_string has been removed from Rust.
This commit is contained in:
Ms2ger 2015-01-20 14:45:36 +01:00
parent 2d5b0e0855
commit 01ed338746
67 changed files with 473 additions and 383 deletions

View file

@ -11,6 +11,7 @@ use geom::scale_factor::ScaleFactor;
use geom::size::TypedSize2D;
use layers::geometry::DevicePixel;
use getopts;
use std::borrow::ToOwned;
use std::collections::HashSet;
use std::cmp;
use std::io;
@ -302,7 +303,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
}
};
let render_api = match opt_match.opt_str("r").unwrap_or("gl".into_string()).as_slice() {
let render_api = match opt_match.opt_str("r").unwrap_or("gl".to_owned()).as_slice() {
"mesa" => RenderApi::Mesa,
"gl" => RenderApi::OpenGL,
_ => {

View file

@ -4,6 +4,7 @@
use opts;
use std::any::Any;
use std::borrow::ToOwned;
#[cfg(not(test))]
use std::io::File;
//use std::mem;
@ -83,7 +84,7 @@ pub fn instrument(f: proc()) {
let task = Local::borrow(None::<Task>);
match task.name {
Some(ref name) => name.to_string(),
None => "unknown".into_string(),
None => "unknown".to_owned(),
}
};
let stats = TaskStats {

View file

@ -523,55 +523,56 @@ def_small_vector_clone_impl!(SmallVec32)
#[cfg(test)]
pub mod tests {
use smallvec::{SmallVec, SmallVec2, SmallVec16};
use std::borrow::ToOwned;
// We heap allocate all these strings so that double frees will show up under valgrind.
#[test]
pub fn test_inline() {
let mut v = SmallVec16::new();
v.push("hello".into_string());
v.push("there".into_string());
v.push("hello".to_owned());
v.push("there".to_owned());
assert_eq!(v.as_slice(), vec![
"hello".into_string(),
"there".into_string(),
"hello".to_owned(),
"there".to_owned(),
].as_slice());
}
#[test]
pub fn test_spill() {
let mut v = SmallVec2::new();
v.push("hello".into_string());
v.push("there".into_string());
v.push("burma".into_string());
v.push("shave".into_string());
v.push("hello".to_owned());
v.push("there".to_owned());
v.push("burma".to_owned());
v.push("shave".to_owned());
assert_eq!(v.as_slice(), vec![
"hello".into_string(),
"there".into_string(),
"burma".into_string(),
"shave".into_string(),
"hello".to_owned(),
"there".to_owned(),
"burma".to_owned(),
"shave".to_owned(),
].as_slice());
}
#[test]
pub fn test_double_spill() {
let mut v = SmallVec2::new();
v.push("hello".into_string());
v.push("there".into_string());
v.push("burma".into_string());
v.push("shave".into_string());
v.push("hello".into_string());
v.push("there".into_string());
v.push("burma".into_string());
v.push("shave".into_string());
v.push("hello".to_owned());
v.push("there".to_owned());
v.push("burma".to_owned());
v.push("shave".to_owned());
v.push("hello".to_owned());
v.push("there".to_owned());
v.push("burma".to_owned());
v.push("shave".to_owned());
assert_eq!(v.as_slice(), vec![
"hello".into_string(),
"there".into_string(),
"burma".into_string(),
"shave".into_string(),
"hello".into_string(),
"there".into_string(),
"burma".into_string(),
"shave".into_string(),
"hello".to_owned(),
"there".to_owned(),
"burma".to_owned(),
"shave".to_owned(),
"hello".to_owned(),
"there".to_owned(),
"burma".to_owned(),
"shave".to_owned(),
].as_slice());
}
}

View file

@ -6,6 +6,7 @@ use geometry::Au;
use cssparser::{mod, RGBA, Color};
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::iter::Filter;
use std::num::Int;
use std::str::{CharEq, CharSplits, FromStr};
@ -16,11 +17,11 @@ pub type StaticCharVec = &'static [char];
pub type StaticStringVec = &'static [&'static str];
pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString {
// We don't use map_default because it would allocate "".into_string() even
// We don't use map_default because it would allocate "".to_owned() even
// for Some.
match *s {
Some(ref s) => s.clone(),
None => "".into_string()
None => "".to_owned()
}
}

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::borrow::ToOwned;
use std::task;
use std::comm::Sender;
use std::task::TaskBuilder;
@ -29,7 +30,7 @@ pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str,
f();
});
let watched_name = name.into_string();
let watched_name = name.to_owned();
let watcher_name = format!("{}Watcher", watched_name);
TaskBuilder::new().named(watcher_name).spawn(proc() {
//rtinstrument::instrument(proc() {