remove two unecessary clones

This commit is contained in:
Skgland
2025-11-18 21:27:23 +01:00
committed by Bennet Bleßmann
parent e4d9692535
commit bf8651db29

View File

@@ -128,9 +128,11 @@ impl Term {
pub fn try_conjunction(value: impl IntoIterator<Item = Term>) -> Option<Self> {
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<Item = Term>) -> Option<Self> {
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
}
})
}
}