Skip to content

Commit 38bc9b9

Browse files
committed
Auto merge of #85975 - the8472:revert-take-tra, r=scottmcm
Revert "implement TrustedRandomAccess for Take iterator adapter" This reverts commit 37a5b51 (#83990). The original change unintentionally caused side-effects from certain iterator chains combining `take`, `zip` and `next_back()` to be omitted which is observable by user code and thus likely a breaking change Technically one could declare it not a breaking change since `Zip`'s API contract is silent about about its backwards iteration behavior but on the other hand there is nothing in the stable Iterator API that could justify the currently observable behavior. And either way, this impact wasn't noticed or discussed in the original PR. Fixes #85969
2 parents c4b5406 + dbc43ec commit 38bc9b9

File tree

1 file changed

+1
-22
lines changed
  • library/core/src/iter/adapters

1 file changed

+1
-22
lines changed

library/core/src/iter/adapters/take.rs

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use crate::cmp;
2-
use crate::iter::{
3-
adapters::zip::try_get_unchecked, adapters::SourceIter, FusedIterator, InPlaceIterable,
4-
TrustedLen, TrustedRandomAccess,
5-
};
2+
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen};
63
use crate::ops::{ControlFlow, Try};
74

85
/// An iterator that only iterates over the first `n` iterations of `iter`.
@@ -114,15 +111,6 @@ where
114111

115112
self.try_fold(init, ok(fold)).unwrap()
116113
}
117-
118-
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> <I as Iterator>::Item
119-
where
120-
Self: TrustedRandomAccess,
121-
{
122-
// SAFETY: the caller must uphold the contract for
123-
// `Iterator::__iterator_get_unchecked`.
124-
unsafe { try_get_unchecked(&mut self.iter, idx) }
125-
}
126114
}
127115

128116
#[unstable(issue = "none", feature = "inplace_iteration")]
@@ -219,12 +207,3 @@ impl<I> FusedIterator for Take<I> where I: FusedIterator {}
219207

220208
#[unstable(feature = "trusted_len", issue = "37572")]
221209
unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}
222-
223-
#[doc(hidden)]
224-
#[unstable(feature = "trusted_random_access", issue = "none")]
225-
unsafe impl<I> TrustedRandomAccess for Take<I>
226-
where
227-
I: TrustedRandomAccess,
228-
{
229-
const MAY_HAVE_SIDE_EFFECT: bool = I::MAY_HAVE_SIDE_EFFECT;
230-
}

0 commit comments

Comments
 (0)