Remove unnecessary to_string calls
This commit removes superfluous to_string calls from various places
This commit is contained in:
parent
99519cc8e6
commit
f8e06c4965
26 changed files with 62 additions and 106 deletions
|
|
@ -228,12 +228,12 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
|
|||
};
|
||||
|
||||
// Transform the contents of the header into a hyphenated string
|
||||
let id = (s.as_slice().words().map(|s| {
|
||||
let id = s.as_slice().words().map(|s| {
|
||||
match s.to_ascii_opt() {
|
||||
Some(s) => s.to_lower().into_str(),
|
||||
None => s.to_string()
|
||||
}
|
||||
}).collect::<Vec<String>>().connect("-")).to_string();
|
||||
}).collect::<Vec<String>>().connect("-");
|
||||
|
||||
// This is a terrible hack working around how hoedown gives us rendered
|
||||
// html for text rather than the raw text.
|
||||
|
|
@ -252,7 +252,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
|
|||
|
||||
let sec = match opaque.toc_builder {
|
||||
Some(ref mut builder) => {
|
||||
builder.push(level as u32, s.to_string(), id.clone())
|
||||
builder.push(level as u32, s.clone(), id.clone())
|
||||
}
|
||||
None => {""}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -370,8 +370,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
|
|||
search_index.push(IndexItem {
|
||||
ty: shortty(item),
|
||||
name: item.name.clone().unwrap(),
|
||||
path: fqp.slice_to(fqp.len() - 1).connect("::")
|
||||
.to_string(),
|
||||
path: fqp.slice_to(fqp.len() - 1).connect("::"),
|
||||
desc: shorter(item.doc_value()).to_string(),
|
||||
parent: Some(did),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -85,10 +85,7 @@ local_data_key!(pub analysiskey: core::CrateAnalysis)
|
|||
type Output = (clean::Crate, Vec<plugins::PluginJson> );
|
||||
|
||||
pub fn main() {
|
||||
std::os::set_exit_status(main_args(std::os::args().iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice()));
|
||||
std::os::set_exit_status(main_args(std::os::args().as_slice()));
|
||||
}
|
||||
|
||||
pub fn opts() -> Vec<getopts::OptGroup> {
|
||||
|
|
@ -184,17 +181,10 @@ pub fn main_args(args: &[String]) -> int {
|
|||
|
||||
match (should_test, markdown_input) {
|
||||
(true, true) => {
|
||||
return markdown::test(input,
|
||||
libs,
|
||||
test_args.move_iter().collect())
|
||||
return markdown::test(input, libs, test_args)
|
||||
}
|
||||
(true, false) => {
|
||||
return test::run(input,
|
||||
cfgs.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect(),
|
||||
libs,
|
||||
test_args)
|
||||
return test::run(input, cfgs, libs, test_args)
|
||||
}
|
||||
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
|
||||
&matches),
|
||||
|
|
@ -273,10 +263,7 @@ fn acquire_input(input: &str,
|
|||
fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
|
||||
let mut default_passes = !matches.opt_present("no-defaults");
|
||||
let mut passes = matches.opt_strs("passes");
|
||||
let mut plugins = matches.opt_strs("plugins")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>();
|
||||
let mut plugins = matches.opt_strs("plugins");
|
||||
|
||||
// First, parse the crate and extract all relevant information.
|
||||
let libs: Vec<Path> = matches.opt_strs("L")
|
||||
|
|
@ -289,7 +276,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
|
|||
let (krate, analysis) = std::task::try(proc() {
|
||||
let cr = cr;
|
||||
core::run_core(libs.move_iter().map(|x| x.clone()).collect(),
|
||||
cfgs.move_iter().map(|x| x.to_string()).collect(),
|
||||
cfgs,
|
||||
&cr)
|
||||
}).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap();
|
||||
info!("finished with rustc");
|
||||
|
|
|
|||
|
|
@ -93,19 +93,10 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
|
|||
|
||||
let (in_header, before_content, after_content) =
|
||||
match (load_external_files(matches.opt_strs("markdown-in-header")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice()),
|
||||
load_external_files(matches.opt_strs("markdown-before-content")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice()),
|
||||
load_external_files(matches.opt_strs("markdown-after-content")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice())) {
|
||||
(Some(a), Some(b), Some(c)) => (a,b,c),
|
||||
_ => return 3
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ pub fn unindent(s: &str) -> String {
|
|||
line.slice_from(min_indent).to_string()
|
||||
}
|
||||
}).collect::<Vec<_>>().as_slice());
|
||||
unindented.connect("\n").to_string()
|
||||
unindented.connect("\n")
|
||||
} else {
|
||||
s.to_string()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue