Update the Serialize impl, too

This commit is contained in:
Oliver Schneider 2017-01-12 20:06:44 +01:00 committed by GitHub
parent 5edfdba940
commit 2d1a60c056

View File

@ -226,7 +226,7 @@ array_impls!(32);
#[cfg(feature = "unstable")]
impl<'a, I> Serialize for Iterator<I>
where I: iter::Iterator, <I as iter::Iterator>::Item: Serialize
where I: IntoIterator, <I as IntoIterator>::Item: Serialize
{
#[inline]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
@ -234,7 +234,7 @@ impl<'a, I> Serialize for Iterator<I>
{
// FIXME: use specialization to prevent invalidating the object in case of clonable iterators?
let iter = match self.0.borrow_mut().take() {
Some(iter) => iter,
Some(iter) => iter.into_iter(),
None => return Err(S::Error::custom("Iterator used twice")),
};
let size = match iter.size_hint() {