Skip to content

Commit

Permalink
impl TrustedRandomAccess for Fuse without FusedIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Mar 25, 2020
1 parent 212e6ce commit 4f429c0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libcore/iter/adapters/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,14 @@ where

unsafe impl<I> TrustedRandomAccess for Fuse<I>
where
I: TrustedRandomAccess + FusedIterator,
I: TrustedRandomAccess,
{
unsafe fn get_unchecked(&mut self, i: usize) -> I::Item {
self.as_inner_mut().get_unchecked(i)
match self.iter {
Some(ref mut iter) => iter.get_unchecked(i),
// SAFETY: the caller asserts there is an item at `i`, so we're not exhausted.
None => intrinsics::unreachable(),
}
}

fn may_have_side_effect() -> bool {
Expand Down

0 comments on commit 4f429c0

Please sign in to comment.