From 3643c60065fdd50bd50465964f8d63a6f863fb93 Mon Sep 17 00:00:00 2001
From: MagisterDallis <194415551+MagisterDallis@users.noreply.github.com>
Date: Wed, 15 Jan 2025 10:38:59 +0100
Subject: [PATCH] apply suggestion

---
 corelib/src/iter/traits/iterator.cairo | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/corelib/src/iter/traits/iterator.cairo b/corelib/src/iter/traits/iterator.cairo
index 043fc5ed017..b69affc919e 100644
--- a/corelib/src/iter/traits/iterator.cairo
+++ b/corelib/src/iter/traits/iterator.cairo
@@ -182,13 +182,9 @@ pub trait Iterator<T> {
     >(
         ref self: T, init: B, f: F,
     ) -> B {
-        let mut accum = init;
         match Self::next(ref self) {
-            Option::Some(x) => {
-                accum = f(accum, x);
-                Self::fold(ref self, accum, f)
-            },
-            Option::None => { accum },
+            Option::None => init,
+            Option::Some(x) => Self::fold(ref self, f(init, x), f),
         }
     }
 }