Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 15ab363

Browse files
committed
not to use Vec
1 parent 3759a66 commit 15ab363

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/cargo-fmt/main.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ fn handle_command_status(status: Result<i32, io::Error>, opts: &getopts::Options
123123
}
124124

125125
fn get_version() -> Result<i32, io::Error> {
126-
let mut status = vec![];
127126
let mut command = Command::new("rustfmt")
128127
.stdout(std::process::Stdio::inherit())
129128
.args(&[String::from("--version")])
@@ -135,13 +134,12 @@ fn get_version() -> Result<i32, io::Error> {
135134
),
136135
_ => e,
137136
})?;
138-
status.push(command.wait()?);
139-
140-
Ok(status
141-
.iter()
142-
.filter_map(|s| if s.success() { None } else { s.code() })
143-
.next()
144-
.unwrap_or(SUCCESS))
137+
let result = command.wait()?;
138+
if result.success() {
139+
Ok(SUCCESS)
140+
} else {
141+
Ok(result.code().unwrap_or(SUCCESS))
142+
}
145143
}
146144

147145
fn format_crate(verbosity: Verbosity, strategy: &CargoFmtStrategy) -> Result<i32, io::Error> {

0 commit comments

Comments
 (0)