From: Skgland Date: Tue, 18 Nov 2025 20:27:23 +0000 (+0100) Subject: remove two unecessary clones X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=bf8651db29b532fe59e78185865aee2b562352b2;p=scryer-prolog.git remove two unecessary clones --- diff --git a/src/machine/lib_machine/mod.rs b/src/machine/lib_machine/mod.rs index fc036940..653fc2a4 100644 --- a/src/machine/lib_machine/mod.rs +++ b/src/machine/lib_machine/mod.rs @@ -128,9 +128,11 @@ impl Term { pub fn try_conjunction(value: impl IntoIterator) -> Option { let mut iter = value.into_iter(); iter.next().map(|first| { - Term::try_conjunction(iter) - .map(|rest| Term::compound(",", [first.clone(), rest])) - .unwrap_or(first) + if let Some(rest) = Term::try_conjunction(iter) { + Term::compound(",", [first, rest]) + } else { + first + } }) } @@ -143,9 +145,11 @@ impl Term { pub fn try_disjunction(value: impl IntoIterator) -> Option { let mut iter = value.into_iter(); iter.next().map(|first| { - Term::try_disjunction(iter) - .map(|rest| Term::compound(";", [first.clone(), rest])) - .unwrap_or(first) + if let Some(rest) = Term::try_disjunction(iter) { + Term::compound(";", [first, rest]) + } else { + first + } }) } }