diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2021-01-31 01:47:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-31 01:47:46 +0100 |
| commit | 709710564aad67c2455034dfc847b6fcc67705e8 (patch) | |
| tree | 0d3650bd3c4b65d43590ae34a029fdfe85e559b9 | |
| parent | 45d24c729c41a8ec737dbfe0b79c67e943d37e7f (diff) | |
| parent | 55d6247f52051e897938e8f65a34c3cc661f5e24 (diff) | |
| download | rust-709710564aad67c2455034dfc847b6fcc67705e8.tar.gz rust-709710564aad67c2455034dfc847b6fcc67705e8.zip | |
Rollup merge of #81562 - the8472:improve-inplaceiterable-docs, r=sfackler
Clarify that InPlaceIterable guarantees extend to all advancing iterator methods. A documentation update that should answer a question that came up in [this zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Safety.20guarantees.20of.20InPlaceIterable/near/223743336) CC `@SkiFire13`
| -rw-r--r-- | library/core/src/iter/traits/marker.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/library/core/src/iter/traits/marker.rs b/library/core/src/iter/traits/marker.rs index ed8eea672f8..c4e21b84863 100644 --- a/library/core/src/iter/traits/marker.rs +++ b/library/core/src/iter/traits/marker.rs @@ -43,12 +43,14 @@ unsafe impl<I: TrustedLen + ?Sized> TrustedLen for &mut I {} /// An iterator that when yielding an item will have taken at least one element /// from its underlying [`SourceIter`]. /// -/// Calling [`next()`] guarantees that at least one value of the iterator's underlying source -/// has been moved out and the result of the iterator chain could be inserted in its place, -/// assuming structural constraints of the source allow such an insertion. +/// Calling any method that advances the iterator, e.g. [`next()`] or [`try_fold()`], +/// guarantees that for each step at least one value of the iterator's underlying source +/// has been moved out and the result of the iterator chain could be inserted +/// in its place, assuming structural constraints of the source allow such an insertion. /// In other words this trait indicates that an iterator pipeline can be collected in place. /// /// [`SourceIter`]: crate::iter::SourceIter /// [`next()`]: Iterator::next +/// [`try_fold()`]: Iterator::try_fold #[unstable(issue = "none", feature = "inplace_iteration")] pub unsafe trait InPlaceIterable: Iterator {} |
