diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-07-08 22:52:55 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-07-09 11:05:32 +0200 |
| commit | 836f32e7697195a482b88883cbbe4a2dd986d8cb (patch) | |
| tree | f5855686978ec62f571011b78f1345a93ddd44e7 /src/libgraphviz | |
| parent | 5b6a4643583c2b580b9a57f48dd94ba5d7824765 (diff) | |
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.)
Diffstat (limited to 'src/libgraphviz')
| -rw-r--r-- | src/libgraphviz/lib.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index f8d80035d97..cd9e677d87f 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -599,7 +599,6 @@ mod tests { use std::io; use std::io::prelude::*; use std::borrow::IntoCow; - use std::iter::repeat; /// each node is an index in a vector in the graph. type Node = usize; @@ -647,7 +646,7 @@ mod tests { fn to_opt_strs(self) -> Vec<Option<&'static str>> { match self { UnlabelledNodes(len) - => repeat(None).take(len).collect(), + => vec![None; len], AllNodesLabelled(lbls) => lbls.into_iter().map( |l|Some(l)).collect(), |
