diff --git a/src/builtins/source.rs b/src/builtins/source.rs index edf8d9bfb..f58867747 100644 --- a/src/builtins/source.rs +++ b/src/builtins/source.rs @@ -86,12 +86,8 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O // Construct argv from our null-terminated list. // This is slightly subtle. If this is a bare `source` with no args then `argv + optind` already // points to the end of argv. Otherwise we want to skip the file name to get to the args if any. - let mut argv_list: Vec = vec![]; let remaining_args = &args[optind + if argc == optind { 0 } else { 1 }..]; - #[allow(clippy::unnecessary_to_owned)] - for arg in remaining_args.iter().copied() { - argv_list.push(arg.to_owned()); - } + let argv_list = remaining_args.iter().map(|&arg| arg.to_owned()).collect(); parser.vars().set_argv(argv_list); let mut retval = reader_read(parser, fd, streams.io_chain);