From 2f31215c0b4d7f8dbec94747a4f134d8eee70c44 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 5 Apr 2021 12:53:39 -0600 Subject: don't use &String where it makes a mess --- src/args.rs | 14 ++++++++++---- src/main.rs | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/args.rs b/src/args.rs index 4f36c03..6a46986 100644 --- a/src/args.rs +++ b/src/args.rs @@ -172,12 +172,18 @@ impl Args { Self::from_given_args_and_given_env(args.into_iter(), env_makeflags) } - pub fn targets(&self) -> impl Iterator { - self.targets_or_macros.iter().filter(|x| !x.contains('=')) + pub fn targets(&self) -> impl Iterator { + self.targets_or_macros + .iter() + .map(AsRef::as_ref) + .filter(|x: &&str| !x.contains('=')) } - pub fn macros(&self) -> impl Iterator { - self.targets_or_macros.iter().filter(|x| x.contains('=')) + pub fn macros(&self) -> impl Iterator { + self.targets_or_macros + .iter() + .map(AsRef::as_ref) + .filter(|x: &&str| x.contains('=')) } } diff --git a/src/main.rs b/src/main.rs index 58d3cba..3d4b19d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,13 +74,13 @@ fn main() -> Result<()> { println!("{}", &makefile); } else { let targets = if args.targets().count() == 0 { - let first_target = makefile.first_non_special_target.clone(); + let first_target = makefile.first_non_special_target.as_deref(); match first_target { Some(x) => vec![x], None => bail!("no targets given on command line or found in makefile."), } } else { - args.targets().cloned().collect() + args.targets().collect() }; for target in targets { -- cgit v1.2.3