Skip to content

Commit 49668de

Browse files
bors[bot]Qqwy
andauthored
702: Adds info about (lack of) object safety to `iter` module documentation. r=cuviper a=Qqwy Because I spent quite a while yesterday and today tracking this problem down, I thought it might be an improvement to the documentation to mention that Rayon's ParallelIterator and friends are not object-safe (and why). (c.f. rayon-rs#628) Co-authored-by: Qqwy/Wiebe-Marten Wijnja <w-m@wmcode.nl> Co-authored-by: Qqwy / Wiebe-Marten <w-m@wmcode.nl>
2 parents fc69e50 + 9acfaa6 commit 49668de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/iter/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
//! to mirror the unstable `std::ops::Try` with implementations for `Option` and
7373
//! `Result`, where `Some`/`Ok` values will let those iterators continue, but
7474
//! `None`/`Err` values will exit early.
75+
//!
76+
//! A note about object safety: It is currently _not_ possible to wrap
77+
//! a `ParallelIterator` (or any trait that depends on it) using a
78+
//! `Box<dyn ParallelIterator>` or other kind of dynamic allocation,
79+
//! because `ParallelIterator` is **not object-safe**.
80+
//! (This keeps the implementation simpler and allows extra optimizations.)
7581
7682
use self::plumbing::*;
7783
use self::private::Try;

0 commit comments

Comments
 (0)