about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-12-30 14:07:47 +0900
committerGitHub <noreply@github.com>2019-12-30 14:07:47 +0900
commit97a7b032988e047aebe1def53b0afc7c5f7356a6 (patch)
tree9c0ac3f72241218148ad1cc12ad492b2bb0e0f7f
parent2c46dd16a592aa30db2a1126d898814e3b5b8dc4 (diff)
parent65e366064f222502c96d0d39102ea6cea9d4bafa (diff)
downloadrust-97a7b032988e047aebe1def53b0afc7c5f7356a6.tar.gz
rust-97a7b032988e047aebe1def53b0afc7c5f7356a6.zip
Rollup merge of #67564 - Mark-Simulacrum:iter-adapter-panic, r=LukasKalbertodt
docs: Iterator adapters have unspecified results after a panic

Fixes #58170.

That issue also has rough consensus from 3 members of the library team for this being the behavior we would like to specify.
-rw-r--r--src/libcore/iter/mod.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs
index 80294de714d..0d5af3986fb 100644
--- a/src/libcore/iter/mod.rs
+++ b/src/libcore/iter/mod.rs
@@ -216,6 +216,11 @@
 //! Common iterator adapters include [`map`], [`take`], and [`filter`].
 //! For more, see their documentation.
 //!
+//! If an iterator adapter panics, the iterator will be in an unspecified (but
+//! memory safe) state.  This state is also not guaranteed to stay the same
+//! across versions of Rust, so you should avoid relying on the exact values
+//! returned by an iterator which panicked.
+//!
 //! [`map`]: trait.Iterator.html#method.map
 //! [`take`]: trait.Iterator.html#method.take
 //! [`filter`]: trait.Iterator.html#method.filter