diff options
Diffstat (limited to 'src/makefile/mod.rs')
-rw-r--r-- | src/makefile/mod.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index 74f1f4b..62cc416 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -161,13 +161,10 @@ impl<'a> Makefile<'a> { } fn special_target_has_prereq(&self, target: &str, name: &str) -> bool { - match self.targets.get(target) { - Some(target) => { - let target = target.borrow(); - target.prerequisites.is_empty() || target.prerequisites.iter().any(|e| e == name) - } - None => false, - } + self.targets.get(target).map_or(false, |target| { + let target = target.borrow(); + target.prerequisites.is_empty() || target.prerequisites.iter().any(|e| e == name) + }) } fn infer_target( @@ -326,10 +323,9 @@ impl<'a> Makefile<'a> { self.targets.put(new_target); } - Ok(self - .targets + self.targets .get(name) - .ok_or_else(|| eyre!("Target {:?} not found!", name))?) + .ok_or_else(|| eyre!("Target {:?} not found!", name)) } pub fn update_target(&self, name: &str) -> Result<()> { @@ -376,7 +372,7 @@ impl<'a> Makefile<'a> { // chosen for the target. In the .DEFAULT rule, the $< macro // shall evaluate to the current target name. // TODO make that actually be the case (rn exists_but_inferring_anyway might fuck that up) - vec![target.prerequisites.get(0).cloned().unwrap_or_default()] + vec![target.prerequisites.first().cloned().unwrap_or_default()] } else if macro_name.starts_with('*') { // The $* macro shall evaluate to the current target name with // its suffix deleted. (GNUism: the match stem) |