Skip to content

Commit d5bfb75

Browse files
committed
uucore: optimise run_util_function
1 parent 1eea517 commit d5bfb75

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/uucore/src/lib/features/benchmark.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ where
3232
F: FnOnce(std::vec::IntoIter<std::ffi::OsString>) -> i32,
3333
{
3434
// Prepend a dummy program name as argv[0] since clap expects it
35-
let mut os_args: Vec<std::ffi::OsString> = vec!["benchmark".into()];
36-
os_args.extend(args.iter().map(|s| (*s).into()));
35+
let os_args = std::iter::once(std::ffi::OsString::from("benchmark"))
36+
.chain(args.iter().map(std::ffi::OsString::from))
37+
.collect::<Vec<_>>();
3738
util_func(os_args.into_iter())
3839
}
3940

0 commit comments

Comments
 (0)