# Trait std::iter::SourceIter[−][src]

    pub unsafe trait SourceIter {
        type Source: Iterator;
        pub unsafe fn as_inner(&mut self) -> &mut Self::Source;
    }

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

This trait provides transitive access to source-stage in an interator-adapter pipeline under the conditions that

- the iterator source `S` itself implements `SourceIter<Source = S>`
- there is a delegating implementation of this trait for each adapter in the pipeline between the source and the pipeline consumer.

When the source is an owning iterator struct (commonly called `IntoIter`) then this can be useful for specializing `FromIterator` implementations or recovering the remaining elements after an iterator has been partially exhausted.

Note that implementations do not necessarily have to provide access to the inner-most source of a pipeline. A stateful intermediate adapter might eagerly evaluate a part of the pipeline and expose its internal storage as source.

The trait is unsafe because implementers must uphold additional safety properties. See `as_inner` for details.

# Examples

Retrieving a partially consumed source:

    let mut iter = vec![9, 9, 9].into_iter().map(|i| i * i);
    let _ = iter.next();
    let mut remainder = std::mem::replace(unsafe { iter.as_inner() }, Vec::new().into_iter());
    println!("n = {} elements remaining", remainder.len());

Run

## Associated Types

### `type Source: Iterator`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

A source stage in an iterator pipeline.

Loading content...

## Required methods

### `pub unsafe fn as_inner(&mut self) -> &mut Self::Source`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

Retrieve the source of an iterator pipeline.

# Safety

Implementations of must return the same mutable reference for their lifetime, unless replaced by a caller. Callers may only replace the reference when they stopped iteration and drop the iterator pipeline after extracting the source.

This means iterator adapters can rely on the source not changing during iteration but they cannot rely on it in their Drop implementations.

Implementing this method means adapters relinquish private-only access to their source and can only rely on guarantees made based on method receiver types. The lack of restricted access also requires that adapters must uphold the source's public API even when they have access to its internals.

Callers in turn must expect the source to be in any state that is consistent with its public API since adapters sitting between it and the source have the same access. In particular an adapter may have consumed more elements than strictly necessary.

The overall goal of these requirements is to let the consumer of a pipeline use

- whatever remains in the source after iteration has stopped
- the memory that has become unused by advancing a consuming iterator

Loading content...

## Implementors

### `impl<S, A, B> SourceIter for Zip<A, B> where
S: Iterator,
B: Iterator,
A: SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, B, I, F> SourceIter for FilterMap<I, F> where
F: FnMut(<I as Iterator>::Item) -> Option<B>,
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, B, I, F> SourceIter for Map<I, F> where
F: FnMut(<I as Iterator>::Item) -> B,
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, B, I, P> SourceIter for MapWhile<I, P> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,
P: FnMut(<I as Iterator>::Item) -> Option<B>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, I> SourceIter for Enumerate<I> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, I> SourceIter for Fuse<I> where
S: Iterator,
I: FusedIterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, I> SourceIter for Peekable<I> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, I> SourceIter for Skip<I> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, I> SourceIter for Take<I> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, I, F> SourceIter for Inspect<I, F> where
F: FnMut(&<I as Iterator>::Item),
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, P, I> SourceIter for Filter<I, P> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,
P: FnMut(&<I as Iterator>::Item) -> bool,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, P, I> SourceIter for SkipWhile<I, P> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,
P: FnMut(&<I as Iterator>::Item) -> bool,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<S, P, I> SourceIter for TakeWhile<I, P> where
S: Iterator,
I: Iterator + SourceIter<Source = S>,
P: FnMut(&<I as Iterator>::Item) -> bool,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<St, F, B, S, I> SourceIter for Scan<I, St, F> where
F: FnMut(&mut St, <I as Iterator>::Item) -> Option<B>,
S: Iterator,
I: Iterator + SourceIter<Source = S>,` [src]

#### `type Source = S`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut Sⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<T> SourceIter for std::collections::binary_heap::IntoIter<T>`[src]

#### `type Source = IntoIter<T>`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut <IntoIter<T> as SourceIter>::Sourceⓘ

### Notable traits for IntoIter<T>

`impl<T> Iterator for IntoIter<T> type Item = T;`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

### `impl<T, A> SourceIter for std::vec::IntoIter<T, A> where
A: Allocator,` [src]

#### `type Source = IntoIter<T, A>`

🔬 This is a nightly-only experimental API. (`inplace_iteration`)

#### `pub unsafe fn as_inner(&mut self) -> &mut <IntoIter<T, A> as SourceIter>::Sourceⓘ

### Notable traits for IntoIter<T, A>

`impl<T, A> Iterator for IntoIter<T, A> where
A: Allocator, type Item = T;`
`[src]

🔬 This is a nightly-only experimental API. (`inplace_iteration`)
Loading content...