diff --git a/src/libcore/iter/adapters/chain.rs b/src/libcore/iter/adapters/chain.rs
index 5defb857d50d..573b096fb463 100644
--- a/src/libcore/iter/adapters/chain.rs
+++ b/src/libcore/iter/adapters/chain.rs
@@ -13,9 +13,14 @@ use super::super::{Iterator, DoubleEndedIterator, FusedIterator, TrustedLen};
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chain {
- pub(in super::super) a: A,
- pub(in super::super) b: B,
- pub(in super::super) state: ChainState,
+ a: A,
+ b: B,
+ state: ChainState,
+}
+impl Chain {
+ pub(in super::super) fn new(a: A, b: B) -> Chain {
+ Chain { a, b, state: ChainState::Both }
+ }
}
// The iterator protocol specifies that iteration ends with the return value
@@ -32,7 +37,7 @@ pub struct Chain {
// The fourth state (neither iterator is remaining) only occurs after Chain has
// returned None once, so we don't need to store this state.
#[derive(Clone, Debug)]
-pub(in super::super) enum ChainState {
+enum ChainState {
// both front and back iterator are remaining
Both,
// only front is remaining
diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs
index a3e0696d2153..355f86f31ce0 100644
--- a/src/libcore/iter/adapters/mod.rs
+++ b/src/libcore/iter/adapters/mod.rs
@@ -13,7 +13,6 @@ mod zip;
pub use self::chain::Chain;
pub use self::flatten::{FlatMap, Flatten};
pub use self::zip::Zip;
-pub(super) use self::chain::ChainState;
pub(super) use self::flatten::{FlattenCompat, flatten_compat};
pub(super) use self::zip::ZipImpl;
pub(crate) use self::zip::TrustedRandomAccess;
diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs
index 1f390d7e0a92..209cf6d9451d 100644
--- a/src/libcore/iter/mod.rs
+++ b/src/libcore/iter/mod.rs
@@ -353,7 +353,7 @@ pub use self::adapters::Flatten;
#[unstable(feature = "iter_copied", issue = "57127")]
pub use self::adapters::Copied;
-use self::adapters::{flatten_compat, ChainState, ZipImpl};
+use self::adapters::{flatten_compat, ZipImpl};
pub(crate) use self::adapters::TrustedRandomAccess;
mod range;
diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs
index 0ce817d02a52..bb4549dc9031 100644
--- a/src/libcore/iter/traits/iterator.rs
+++ b/src/libcore/iter/traits/iterator.rs
@@ -6,7 +6,7 @@ use super::super::{Chain, Cycle, Copied, Cloned, Enumerate, Filter, FilterMap, F
use super::super::{Flatten, FlatMap, flatten_compat};
use super::super::{Inspect, Map, Peekable, Scan, Skip, SkipWhile, StepBy, Take, TakeWhile, Rev};
use super::super::{Zip, Sum, Product};
-use super::super::{ChainState, FromIterator, ZipImpl};
+use super::super::{FromIterator, ZipImpl};
fn _assert_is_object_safe(_: &dyn Iterator- ) {}
@@ -425,7 +425,7 @@ pub trait Iterator {
fn chain(self, other: U) -> Chain where
Self: Sized, U: IntoIterator
- ,
{
- Chain{a: self, b: other.into_iter(), state: ChainState::Both}
+ Chain::new(self, other.into_iter())
}
/// 'Zips up' two iterators into a single iterator of pairs.