Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "implement TrustedRandomAccess for Take iterator adapter" #85975

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions library/core/src/iter/adapters/take.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use crate::cmp;
use crate::iter::{
adapters::zip::try_get_unchecked, adapters::SourceIter, FusedIterator, InPlaceIterable,
TrustedLen, TrustedRandomAccess,
};
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen};
use crate::ops::{ControlFlow, Try};

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

self.try_fold(init, ok(fold)).unwrap()
}

unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> <I as Iterator>::Item
where
Self: TrustedRandomAccess,
{
// SAFETY: the caller must uphold the contract for
// `Iterator::__iterator_get_unchecked`.
unsafe { try_get_unchecked(&mut self.iter, idx) }
}
}

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

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}

#[doc(hidden)]
#[unstable(feature = "trusted_random_access", issue = "none")]
unsafe impl<I> TrustedRandomAccess for Take<I>
where
I: TrustedRandomAccess,
{
const MAY_HAVE_SIDE_EFFECT: bool = I::MAY_HAVE_SIDE_EFFECT;
}