Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions library/core/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,30 @@ macro_rules! impl_fn_for_zst {
)+
}
}

// Used by both iter and range
macro_rules! impl_fold_via_try_fold {
(fold -> try_fold) => {
impl_fold_via_try_fold! { @internal fold -> try_fold }
};
(rfold -> try_rfold) => {
impl_fold_via_try_fold! { @internal rfold -> try_rfold }
};
(spec_fold -> spec_try_fold) => {
impl_fold_via_try_fold! { @internal spec_fold -> spec_try_fold }
};
(spec_rfold -> spec_try_rfold) => {
impl_fold_via_try_fold! { @internal spec_rfold -> spec_try_rfold }
};
(@internal $fold:ident -> $try_fold:ident) => {
#[inline]
fn $fold<AAA, FFF>(mut self, init: AAA, fold: FFF) -> AAA
where
FFF: FnMut(AAA, Self::Item) -> AAA,
{
use crate::ops::NeverShortCircuit;

self.$try_fold(init, NeverShortCircuit::wrap_mut_2(fold)).0
}
};
}
27 changes: 0 additions & 27 deletions library/core/src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,33 +355,6 @@

#![stable(feature = "rust1", since = "1.0.0")]

// This needs to be up here in order to be usable in the child modules
macro_rules! impl_fold_via_try_fold {
(fold -> try_fold) => {
impl_fold_via_try_fold! { @internal fold -> try_fold }
};
(rfold -> try_rfold) => {
impl_fold_via_try_fold! { @internal rfold -> try_rfold }
};
(spec_fold -> spec_try_fold) => {
impl_fold_via_try_fold! { @internal spec_fold -> spec_try_fold }
};
(spec_rfold -> spec_try_rfold) => {
impl_fold_via_try_fold! { @internal spec_rfold -> spec_try_rfold }
};
(@internal $fold:ident -> $try_fold:ident) => {
#[inline]
fn $fold<AAA, FFF>(mut self, init: AAA, fold: FFF) -> AAA
where
FFF: FnMut(AAA, Self::Item) -> AAA,
{
use crate::ops::NeverShortCircuit;

self.$try_fold(init, NeverShortCircuit::wrap_mut_2(fold)).0
}
};
}

#[unstable(feature = "iter_array_chunks", issue = "100450")]
pub use self::adapters::ArrayChunks;
#[unstable(feature = "std_internals", issue = "none")]
Expand Down
Loading
Loading