File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -564,12 +564,16 @@ pub(crate) fn execute_external_command(
564564 args : & [ CommandArg ] ,
565565) -> Result < ExecutionSpawnResult , error:: Error > {
566566 // Filter out the args; we only want strings.
567- let mut cmd_args = vec ! [ ] ;
568- for arg in args {
569- if let CommandArg :: String ( s) = arg {
570- cmd_args. push ( s) ;
571- }
572- }
567+ let cmd_args = args
568+ . iter ( )
569+ . filter_map ( |e| {
570+ if let CommandArg :: String ( s) = e {
571+ Some ( s)
572+ } else {
573+ None
574+ }
575+ } )
576+ . collect :: < Vec < _ > > ( ) ;
573577
574578 // Before we lose ownership of the open files, figure out if stdin will be a terminal.
575579 let child_stdin_is_terminal = context
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ mod unix {
1818 . unwrap ( )
1919 }
2020
21- fn parse ( tokens : & Vec < Token > ) -> brush_parser:: ast:: Program {
21+ fn parse ( tokens : & [ Token ] ) -> brush_parser:: ast:: Program {
2222 parse_tokens ( tokens, & brush_parser:: ParserOptions :: default ( ) ) . unwrap ( )
2323 }
2424
Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ impl<R: std::io::BufRead> Parser<R> {
184184/// * `tokens` - The tokens to parse.
185185/// * `options` - The options to use when parsing.
186186pub fn parse_tokens (
187- tokens : & Vec < Token > ,
187+ tokens : & [ Token ] ,
188188 options : & ParserOptions ,
189189) -> Result < ast:: Program , crate :: error:: ParseError > {
190190 let parse_result = peg:: token_parser:: program ( & Tokens { tokens } , options) ;
@@ -193,7 +193,7 @@ pub fn parse_tokens(
193193
194194fn parse_result_to_error < R > (
195195 parse_result : Result < R , :: peg:: error:: ParseError < usize > > ,
196- tokens : & Vec < Token > ,
196+ tokens : & [ Token ] ,
197197) -> Result < R , crate :: error:: ParseError >
198198where
199199 R : std:: fmt:: Debug ,
@@ -205,10 +205,7 @@ where
205205 }
206206 Err ( parse_error) => {
207207 tracing:: debug!( target: "parse" , "Parse error: {:?}" , parse_error) ;
208- Err ( crate :: error:: convert_peg_parse_error (
209- & parse_error,
210- tokens. as_slice ( ) ,
211- ) )
208+ Err ( crate :: error:: convert_peg_parse_error ( & parse_error, tokens) )
212209 }
213210 }
214211}
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ mod tests {
168168 fn basic_prompt ( ) -> Result < ( ) > {
169169 assert_eq ! (
170170 parse( r"\u@\h:\w$ " ) ?,
171- vec! [
171+ & [
172172 PromptPiece :: CurrentUser ,
173173 PromptPiece :: Literal ( "@" . to_owned( ) ) ,
174174 PromptPiece :: Hostname {
@@ -190,7 +190,7 @@ mod tests {
190190 fn brackets_and_vars ( ) -> Result < ( ) > {
191191 assert_eq ! (
192192 parse( r"\[$foo\]\u > " ) ?,
193- vec! [
193+ & [
194194 PromptPiece :: StartNonPrintingSequence ,
195195 PromptPiece :: Literal ( "$foo" . to_owned( ) ) ,
196196 PromptPiece :: EndNonPrintingSequence ,
You can’t perform that action at this time.
0 commit comments