// Do a little dance to make writing safer - write to a temp file
// rename the original to a .bk, then rename the temp file to the
// original.
- let tmp_name = filename.to_string() + ".tmp";
- let bk_name = filename.to_string() + ".bk";
+ let tmp_name = filename.to_owned() + ".tmp";
+ let bk_name = filename.to_owned() + ".bk";
{
// Write text to temp file
let mut tmp_file = try!(File::create(&tmp_name));
try!(::std::fs::rename(tmp_name, filename));
}
WriteMode::NewFile(extn) => {
- let filename = filename.to_string() + "." + extn;
+ let filename = filename.to_owned() + "." + extn;
let mut file = try!(File::create(&filename));
try!(write!(file, "{}", text));
}
&None => String::new(),
};
let mut_str = match m {
- &ast::Mutability::MutMutable => "mut ".to_string(),
+ &ast::Mutability::MutMutable => "mut ".to_owned(),
&ast::Mutability::MutImmutable => String::new(),
};
arg_item_strs[0] = format!("&{}{}self", lt_str, mut_str);
arg_item_strs[0] = format!("self: {}", pprust::ty_to_string(ty));
}
ast::ExplicitSelf_::SelfValue(_) => {
- arg_item_strs[0] = "self".to_string();
+ arg_item_strs[0] = "self".to_owned();
min_args = 2;
}
_ => {}
// Comments between args
let mut arg_comments = Vec::new();
if min_args == 2 {
- arg_comments.push("".to_string());
+ arg_comments.push("".to_owned());
}
// TODO if there are no args, there might still be a comment, but without
// spans for the comment or parens, there is no chance of getting it right.
} else if snippet.ends_with(separator) {
snippet = snippet[..snippet.len()-separator.len()].trim_matches(white_space);
}
- result.push(snippet.to_string());
+ result.push(snippet.to_owned());
prev_end = get_hi(&item);
}
// Get the last commment.
let snippet = &snippet[..snippet.find(terminator)
.unwrap_or(snippet.find(separator).unwrap_or(snippet.len()))];
let snippet = snippet.trim();
- result.push(snippet.to_string());
+ result.push(snippet.to_owned());
result
}
fn rewrite_return(&self, ret: &ast::FunctionRetTy) -> String {
match *ret {
ast::FunctionRetTy::DefaultReturn(_) => String::new(),
- ast::FunctionRetTy::NoReturn(_) => "-> !".to_string(),
- ast::FunctionRetTy::Return(ref ty) => "-> ".to_string() + &pprust::ty_to_string(ty),
+ ast::FunctionRetTy::NoReturn(_) => "-> !".to_owned(),
+ ast::FunctionRetTy::Return(ref ty) => "-> ".to_owned() + &pprust::ty_to_string(ty),
}
}
let path = entry.unwrap().path();
let file_name = path.to_str().unwrap();
println!("Testing '{}'...", file_name);
- run(vec!["rustfmt".to_string(), file_name.to_string()], WriteMode::Return(HANDLE_RESULT));
+ run(vec!["rustfmt".to_owned(), file_name.to_owned()], WriteMode::Return(HANDLE_RESULT));
count += 1;
}
// And also dogfood ourselves!
println!("Testing 'src/mod.rs'...");
- run(vec!["rustfmt".to_string(), "src/mod.rs".to_string()], WriteMode::Return(HANDLE_RESULT));
+ run(vec!["rustfmt".to_owned(), "src/mod.rs".to_owned()], WriteMode::Return(HANDLE_RESULT));
count += 1;
// Display results