diff --git a/src/lib.rs b/src/lib.rs index f4de79c50..1a847d42b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -393,16 +393,16 @@ macro_rules! izip { /// ``` macro_rules! chain { () => { - core::iter::empty() + $crate::__std_iter::empty() }; ($first:expr $(, $rest:expr )* $(,)?) => { { - let iter = core::iter::IntoIterator::into_iter($first); + let iter = $crate::__std_iter::IntoIterator::into_iter($first); $( let iter = - core::iter::Iterator::chain( + $crate::__std_iter::Iterator::chain( iter, - core::iter::IntoIterator::into_iter($rest)); + $crate::__std_iter::IntoIterator::into_iter($rest)); )* iter } diff --git a/tests/macros_hygiene.rs b/tests/macros_hygiene.rs index 20b59fba8..e6e895555 100644 --- a/tests/macros_hygiene.rs +++ b/tests/macros_hygiene.rs @@ -1,3 +1,8 @@ +mod alloc {} +mod core {} +mod either {} +mod std {} + #[test] fn iproduct_hygiene() { let _ = itertools::iproduct!(); @@ -12,3 +17,11 @@ fn izip_hygiene() { let _ = itertools::izip!(0..6, 0..9); let _ = itertools::izip!(0..6, 0..9, 0..12); } + +#[test] +fn chain_hygiene() { + let _: ::std::iter::Empty = itertools::chain!(); + let _ = itertools::chain!(0..6); + let _ = itertools::chain!(0..6, 0..9); + let _ = itertools::chain!(0..6, 0..9, 0..12); +}