about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-08-23 07:46:52 -0700
committerGitHub <noreply@github.com>2016-08-23 07:46:52 -0700
commit0bd99f9d5c3bb10920f33819b38392137f7bfa11 (patch)
treec4ab1e85690bc75a19094186ed62cbed6ef3eaca /src/liballoc
parent43204fff5d0a656f8a94bfff3129e04bc9d30ad4 (diff)
parentde91872a3337dddf9a0d27df7bfb64f3965c81b0 (diff)
downloadrust-0bd99f9d5c3bb10920f33819b38392137f7bfa11.tar.gz
rust-0bd99f9d5c3bb10920f33819b38392137f7bfa11.zip
Auto merge of #35656 - Stebalien:fused, r=alexcrichton
Implement 1581 (FusedIterator)

* [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642.
* [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be?
* [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice.
* I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`.
* `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`.

Closes: #35602 (Tracking Issue)
Implements: rust-lang/rfcs#1581
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs4
-rw-r--r--src/liballoc/lib.rs2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 7ba5ca30941..dae12f6e8bd 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -61,6 +61,7 @@ use core::borrow;
 use core::cmp::Ordering;
 use core::fmt;
 use core::hash::{self, Hash};
+use core::iter::FusedIterator;
 use core::marker::{self, Unsize};
 use core::mem;
 use core::ops::{CoerceUnsized, Deref, DerefMut};
@@ -529,6 +530,9 @@ impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
 
+#[unstable(feature = "fused", issue = "35602")]
+impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}
+
 
 /// `FnBox` is a version of the `FnOnce` intended for use with boxed
 /// closure objects. The idea is that where one would normally store a
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 0293d5402c4..90037f813cd 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -91,7 +91,7 @@
 #![feature(unsafe_no_drop_flag, filling_drop)]
 #![feature(unsize)]
 
-#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))]
+#![cfg_attr(not(test), feature(fused, raw, fn_traits, placement_new_protocol))]
 #![cfg_attr(test, feature(test, box_heap))]
 
 // Allow testing this library