Skip to content

Commit 7d99416

Browse files
committed
Provide justification for using atomic collect counts
1 parent 405b244 commit 7d99416

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/iter/collect/consumer.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ use std::sync::atomic::{AtomicUsize, Ordering};
77
pub struct CollectConsumer<'c, T: Send + 'c> {
88
/// Tracks how many items we successfully wrote. Used to guarantee
99
/// safety in the face of panics or buggy parallel iterators.
10+
///
11+
/// In theory we could just produce this as a `CollectConsumer::Result`,
12+
/// folding local counts and reducing by addition, but that requires a
13+
/// certain amount of trust that the producer driving this will behave
14+
/// itself. Since this count is important to the safety of marking the
15+
/// memory initialized (`Vec::set_len`), we choose to keep it internal.
1016
writes: &'c AtomicUsize,
1117

1218
/// A slice covering the target memory, not yet initialized!

0 commit comments

Comments
 (0)