提交 01e83a36 编写于 作者: M Mark Simulacrum

Don't allocate args in order to run find.

上级 7a75d2be
......@@ -122,16 +122,15 @@ pub fn parse(args: &[String]) -> Flags {
// the subcommand. Therefore we must manually identify the subcommand first, so that we can
// complete the definition of the options. Then we can use the getopt::Matches object from
// there on out.
let mut possible_subcommands = args.iter().collect::<Vec<_>>();
possible_subcommands.retain(|&s|
(s == "build")
|| (s == "test")
|| (s == "bench")
|| (s == "doc")
|| (s == "clean")
|| (s == "dist")
|| (s == "install"));
let subcommand = match possible_subcommands.first() {
let subcommand = args.iter().find(|&s|
(s == "build")
|| (s == "test")
|| (s == "bench")
|| (s == "doc")
|| (s == "clean")
|| (s == "dist")
|| (s == "install"));
let subcommand = match subcommand {
Some(s) => s,
None => {
// No subcommand -- show the general usage and subcommand help
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册