Replace the remaining to_string calls by into_string calls.

This commit is contained in:
Ms2ger 2014-12-27 16:48:27 +01:00
parent 37a97f3273
commit b6117a57aa
12 changed files with 43 additions and 42 deletions

View file

@ -39,10 +39,10 @@ macro_rules! css_properties(
( $([$getter:ident, $setter:ident, $cssprop:expr]),* ) => ( ( $([$getter:ident, $setter:ident, $cssprop:expr]),* ) => (
$( $(
fn $getter(self) -> DOMString { fn $getter(self) -> DOMString {
self.GetPropertyValue($cssprop.to_string()) self.GetPropertyValue($cssprop.into_string())
} }
fn $setter(self, value: DOMString) { fn $setter(self, value: DOMString) {
self.SetPropertyValue($cssprop.to_string(), value).unwrap(); self.SetPropertyValue($cssprop.into_string(), value).unwrap();
} }
)* )*
); );
@ -123,7 +123,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
} }
}); });
result.unwrap_or("".to_string()) result.unwrap_or("".into_string())
} }
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue // http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
@ -145,7 +145,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
// Step 2.2.2 & 2.2.3 // Step 2.2.2 & 2.2.3
match declaration { match declaration {
Some(declaration) => list.push(declaration), Some(declaration) => list.push(declaration),
None => return "".to_string(), None => return "".into_string(),
} }
} }
@ -157,7 +157,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
if let Some(ref declaration) = self.get_declaration(&property) { if let Some(ref declaration) = self.get_declaration(&property) {
serialize_value(declaration) serialize_value(declaration)
} else { } else {
"".to_string() "".into_string()
} }
} }
@ -174,15 +174,15 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
.map(|longhand| self.GetPropertyPriority(longhand.clone())) .map(|longhand| self.GetPropertyPriority(longhand.clone()))
.all(|priority| priority.as_slice() == "important") { .all(|priority| priority.as_slice() == "important") {
return "important".to_string(); return "important".into_string();
} }
// Step 3 // Step 3
} else if self.get_important_declaration(&property).is_some() { } else if self.get_important_declaration(&property).is_some() {
return "important".to_string(); return "important".into_string();
} }
// Step 4 // Step 4
"".to_string() "".into_string()
} }
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty // http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
@ -287,7 +287,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue // http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult { fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult {
self.SetProperty(property, value, "".to_string()) self.SetProperty(property, value, "".into_string())
} }
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty // http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
@ -326,12 +326,12 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat // http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn CssFloat(self) -> DOMString { fn CssFloat(self) -> DOMString {
self.GetPropertyValue("float".to_string()) self.GetPropertyValue("float".into_string())
} }
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat // http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn SetCssFloat(self, value: DOMString) -> ErrorResult { fn SetCssFloat(self, value: DOMString) -> ErrorResult {
self.SetPropertyValue("float".to_string(), value) self.SetPropertyValue("float".into_string(), value)
} }
fn IndexedGetter(self, index: u32, found: &mut bool) -> DOMString { fn IndexedGetter(self, index: u32, found: &mut bool) -> DOMString {

View file

@ -167,7 +167,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> {
let element: JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(self);
element.get_attribute(ns!(""), &Atom::from_slice(to_snake_case(name).as_slice())).map(|attr| { element.get_attribute(ns!(""), &Atom::from_slice(to_snake_case(name).as_slice())).map(|attr| {
let attr = attr.root(); let attr = attr.root();
attr.value().as_slice().to_string() attr.value().as_slice().into_string()
}) })
} }

View file

@ -210,7 +210,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
window.evaluate_script_with_result(source.as_slice(), url.serialize().as_slice()); window.evaluate_script_with_result(source.as_slice(), url.serialize().as_slice());
let event = Event::new(GlobalRef::Window(*window), let event = Event::new(GlobalRef::Window(*window),
"load".to_string(), "load".into_string(),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable).root(); EventCancelable::NotCancelable).root();
event.set_trusted(true); event.set_trusted(true);

View file

@ -1199,7 +1199,7 @@ impl ScriptTask {
let y = point.y.to_i32().unwrap_or(0); let y = point.y.to_i32().unwrap_or(0);
let mouse_event = MouseEvent::new(*window, let mouse_event = MouseEvent::new(*window,
"mousemove".to_string(), "mousemove".into_string(),
true, true,
true, true,
Some(*window), Some(*window),

View file

@ -2484,7 +2484,7 @@ impl<T: Show> DeclaredValue<T> {
match self { match self {
&DeclaredValue::SpecifiedValue(ref inner) => Some(format!("{}", inner)), &DeclaredValue::SpecifiedValue(ref inner) => Some(format!("{}", inner)),
&DeclaredValue::Initial => None, &DeclaredValue::Initial => None,
&DeclaredValue::Inherit => Some("inherit".to_string()), &DeclaredValue::Inherit => Some("inherit".into_string()),
} }
} }
} }
@ -2509,10 +2509,10 @@ impl PropertyDeclaration {
match self { match self {
% for property in LONGHANDS: % for property in LONGHANDS:
% if property.derived_from is None: % if property.derived_from is None:
&PropertyDeclaration::${property.camel_case}Declaration(..) => "${property.name}".to_string(), &PropertyDeclaration::${property.camel_case}Declaration(..) => "${property.name}".into_string(),
% endif % endif
% endfor % endfor
_ => "".to_string(), _ => "".into_string(),
} }
} }
@ -3201,7 +3201,7 @@ pub fn longhands_from_shorthand(shorthand: &str) -> Option<Vec<String>> {
% for property in SHORTHANDS: % for property in SHORTHANDS:
"${property.name}" => Some(vec!( "${property.name}" => Some(vec!(
% for sub in property.sub_properties: % for sub in property.sub_properties:
"${sub.name}".to_string(), "${sub.name}".into_string(),
% endfor % endfor
)), )),
% endfor % endfor

View file

@ -297,7 +297,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
} }
}; };
let render_api = match opt_match.opt_str("r").unwrap_or("gl".to_string()).as_slice() { let render_api = match opt_match.opt_str("r").unwrap_or("gl".into_string()).as_slice() {
"mesa" => RenderApi::Mesa, "mesa" => RenderApi::Mesa,
"gl" => RenderApi::OpenGL, "gl" => RenderApi::OpenGL,
_ => { _ => {

View file

@ -83,7 +83,7 @@ pub fn instrument(f: proc()) {
let task = Local::borrow(None::<Task>); let task = Local::borrow(None::<Task>);
match task.name { match task.name {
Some(ref name) => name.to_string(), Some(ref name) => name.to_string(),
None => "unknown".to_string(), None => "unknown".into_string(),
} }
}; };
let stats = TaskStats { let stats = TaskStats {

View file

@ -529,34 +529,34 @@ pub mod tests {
#[test] #[test]
pub fn test_inline() { pub fn test_inline() {
let mut v = SmallVec16::new(); let mut v = SmallVec16::new();
v.push("hello".to_string()); v.push("hello".into_string());
v.push("there".to_string()); v.push("there".into_string());
assert_eq!(v.as_slice(), vec!["hello".to_string(), "there".to_string()].as_slice()); assert_eq!(v.as_slice(), vec!["hello".into_string(), "there".into_string()].as_slice());
} }
#[test] #[test]
pub fn test_spill() { pub fn test_spill() {
let mut v = SmallVec2::new(); let mut v = SmallVec2::new();
v.push("hello".to_string()); v.push("hello".into_string());
v.push("there".to_string()); v.push("there".into_string());
v.push("burma".to_string()); v.push("burma".into_string());
v.push("shave".to_string()); v.push("shave".into_string());
assert_eq!(v.as_slice(), vec!["hello".to_string(), "there".to_string(), "burma".to_string(), "shave".to_string()].as_slice()); assert_eq!(v.as_slice(), vec!["hello".into_string(), "there".into_string(), "burma".into_string(), "shave".into_string()].as_slice());
} }
#[test] #[test]
pub fn test_double_spill() { pub fn test_double_spill() {
let mut v = SmallVec2::new(); let mut v = SmallVec2::new();
v.push("hello".to_string()); v.push("hello".into_string());
v.push("there".to_string()); v.push("there".into_string());
v.push("burma".to_string()); v.push("burma".into_string());
v.push("shave".to_string()); v.push("shave".into_string());
v.push("hello".to_string()); v.push("hello".into_string());
v.push("there".to_string()); v.push("there".into_string());
v.push("burma".to_string()); v.push("burma".into_string());
v.push("shave".to_string()); v.push("shave".into_string());
assert_eq!(v.as_slice(), vec![ assert_eq!(v.as_slice(), vec![
"hello".to_string(), "there".to_string(), "burma".to_string(), "shave".to_string(), "hello".to_string(), "there".to_string(), "burma".to_string(), "shave".to_string(), "hello".into_string(), "there".into_string(), "burma".into_string(), "shave".into_string(), "hello".into_string(), "there".into_string(), "burma".into_string(), "shave".into_string(),
].as_slice()); ].as_slice());
} }
} }

View file

@ -16,10 +16,11 @@ pub type StaticCharVec = &'static [char];
pub type StaticStringVec = &'static [&'static str]; pub type StaticStringVec = &'static [&'static str];
pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString { pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString {
// We don't use map_default because it would allocate "".to_string() even for Some. // We don't use map_default because it would allocate "".into_string() even
// for Some.
match *s { match *s {
Some(ref s) => s.clone(), Some(ref s) => s.clone(),
None => "".to_string() None => "".into_string()
} }
} }

View file

@ -42,7 +42,7 @@ pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str,
TaskBuilder::new().named(name).try_future(with_state) TaskBuilder::new().named(name).try_future(with_state)
}; };
let watched_name = name.to_string(); let watched_name = name.into_string();
let watcher_name = format!("{}Watcher", watched_name); let watcher_name = format!("{}Watcher", watched_name);
TaskBuilder::new().named(watcher_name).spawn(proc() { TaskBuilder::new().named(watcher_name).spawn(proc() {
rtinstrument::instrument(proc() { rtinstrument::instrument(proc() {

View file

@ -107,7 +107,7 @@ fn browser_host_create(window_info: &cef_window_info_t,
callback_executed: bool) callback_executed: bool)
-> CefBrowser { -> CefBrowser {
let mut urls = Vec::new(); let mut urls = Vec::new();
urls.push("http://s27.postimg.org/vqbtrolyr/servo.jpg".to_string()); urls.push("http://s27.postimg.org/vqbtrolyr/servo.jpg".into_string());
let mut opts = opts::default_opts(); let mut opts = opts::default_opts();
opts.urls = urls; opts.urls = urls;
let browser = ServoCefBrowser::new(window_info, client).as_cef_interface(); let browser = ServoCefBrowser::new(window_info, client).as_cef_interface();

View file

@ -76,7 +76,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
message_queue.replace(Some(RefCell::new(Vec::new()))); message_queue.replace(Some(RefCell::new(Vec::new())));
let urls = vec![HOME_URL.to_string()]; let urls = vec![HOME_URL.into_string()];
opts::set_opts(opts::Opts { opts::set_opts(opts::Opts {
urls: urls, urls: urls,
n_paint_threads: 1, n_paint_threads: 1,