]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/iter/adapters/mod.rs
Use a macro to not have to copy-paste `ConstFnMutClosure::new(&mut fold, NeverShortCi...
[rust.git] / library / core / src / iter / adapters / mod.rs
index de3a534f81b8adf4b0655e4f1471232ec45fde64..8cc2b7cec41650f273669b836593f809cbe4a899 100644 (file)
@@ -1,6 +1,5 @@
-use crate::const_closure::ConstFnMutClosure;
 use crate::iter::{InPlaceIterable, Iterator};
-use crate::ops::{ChangeOutputType, ControlFlow, FromResidual, NeverShortCircuit, Residual, Try};
+use crate::ops::{ChangeOutputType, ControlFlow, FromResidual, Residual, Try};
 
 mod array_chunks;
 mod by_ref_sized;
@@ -204,13 +203,7 @@ fn try_fold<B, F, T>(&mut self, init: B, mut f: F) -> T
             .into_try()
     }
 
-    fn fold<B, F>(mut self, init: B, mut fold: F) -> B
-    where
-        Self: Sized,
-        F: FnMut(B, Self::Item) -> B,
-    {
-        self.try_fold(init, ConstFnMutClosure::new(&mut fold, NeverShortCircuit::wrap_mut_2_imp)).0
-    }
+    impl_fold_via_try_fold! { fold -> try_fold }
 }
 
 #[unstable(issue = "none", feature = "inplace_iteration")]