mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Replace the remaining to_string calls by into_string calls.
This commit is contained in:
parent
37a97f3273
commit
b6117a57aa
12 changed files with 43 additions and 42 deletions
|
@ -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,
|
||||
"gl" => RenderApi::OpenGL,
|
||||
_ => {
|
||||
|
|
|
@ -83,7 +83,7 @@ pub fn instrument(f: proc()) {
|
|||
let task = Local::borrow(None::<Task>);
|
||||
match task.name {
|
||||
Some(ref name) => name.to_string(),
|
||||
None => "unknown".to_string(),
|
||||
None => "unknown".into_string(),
|
||||
}
|
||||
};
|
||||
let stats = TaskStats {
|
||||
|
|
|
@ -529,34 +529,34 @@ pub mod tests {
|
|||
#[test]
|
||||
pub fn test_inline() {
|
||||
let mut v = SmallVec16::new();
|
||||
v.push("hello".to_string());
|
||||
v.push("there".to_string());
|
||||
assert_eq!(v.as_slice(), vec!["hello".to_string(), "there".to_string()].as_slice());
|
||||
v.push("hello".into_string());
|
||||
v.push("there".into_string());
|
||||
assert_eq!(v.as_slice(), vec!["hello".into_string(), "there".into_string()].as_slice());
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_spill() {
|
||||
let mut v = SmallVec2::new();
|
||||
v.push("hello".to_string());
|
||||
v.push("there".to_string());
|
||||
v.push("burma".to_string());
|
||||
v.push("shave".to_string());
|
||||
assert_eq!(v.as_slice(), vec!["hello".to_string(), "there".to_string(), "burma".to_string(), "shave".to_string()].as_slice());
|
||||
v.push("hello".into_string());
|
||||
v.push("there".into_string());
|
||||
v.push("burma".into_string());
|
||||
v.push("shave".into_string());
|
||||
assert_eq!(v.as_slice(), vec!["hello".into_string(), "there".into_string(), "burma".into_string(), "shave".into_string()].as_slice());
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_double_spill() {
|
||||
let mut v = SmallVec2::new();
|
||||
v.push("hello".to_string());
|
||||
v.push("there".to_string());
|
||||
v.push("burma".to_string());
|
||||
v.push("shave".to_string());
|
||||
v.push("hello".to_string());
|
||||
v.push("there".to_string());
|
||||
v.push("burma".to_string());
|
||||
v.push("shave".to_string());
|
||||
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());
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,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 "".to_string() even for Some.
|
||||
// We don't use map_default because it would allocate "".into_string() even
|
||||
// for Some.
|
||||
match *s {
|
||||
Some(ref s) => s.clone(),
|
||||
None => "".to_string()
|
||||
None => "".into_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
};
|
||||
|
||||
let watched_name = name.to_string();
|
||||
let watched_name = name.into_string();
|
||||
let watcher_name = format!("{}Watcher", watched_name);
|
||||
TaskBuilder::new().named(watcher_name).spawn(proc() {
|
||||
rtinstrument::instrument(proc() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue