Use vec![elt; n] where possible
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
This commit is contained in:
parent
5b6a464358
commit
836f32e769
31 changed files with 61 additions and 91 deletions
|
@ -1920,7 +1920,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
|||
try!(write!(w, r#"<script type="text/javascript" async
|
||||
src="{root_path}/implementors/{path}/{ty}.{name}.js">
|
||||
</script>"#,
|
||||
root_path = repeat("..").take(cx.current.len()).collect::<Vec<_>>().connect("/"),
|
||||
root_path = vec![".."; cx.current.len()].connect("/"),
|
||||
path = if ast_util::is_local(it.def_id) {
|
||||
cx.current.connect("/")
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue