Skip to content

Commit

Permalink
remove clone requirement on fold (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtak- authored Dec 30, 2024
1 parent 9f06254 commit 319b9c4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub trait Language: Debug + Clone + Eq + Ord + Hash {
fn try_for_each<E, F>(&self, mut f: F) -> Result<(), E>
where
F: FnMut(Id) -> Result<(), E>,
E: Clone,
{
self.fold(Ok(()), |res, id| res.and_then(|_| f(id)))
}
Expand Down Expand Up @@ -97,10 +96,11 @@ pub trait Language: Debug + Clone + Eq + Ord + Hash {
fn fold<F, T>(&self, init: T, mut f: F) -> T
where
F: FnMut(T, Id) -> T,
T: Clone,
{
let mut acc = init;
self.for_each(|id| acc = f(acc.clone(), id));
for id in self.children().iter().copied() {
acc = f(acc, id)
}
acc
}

Expand Down

0 comments on commit 319b9c4

Please sign in to comment.