std::slice::Iter - Rust (original) (raw)

pub fn [as_slice](#method.as%5Fslice)(&self) -> [&'a [T]](../primitive.slice.html)

1.4.0

[src]

View the underlying data as a subslice of the original data.

This has the same lifetime as the original slice, and so the iterator can continue to be used while this exists.

Basic usage:

let slice = &[1, 2, 3];

let mut iter = slice.iter();

println!("{:?}", iter.as_slice());

iter.next();

println!("{:?}", iter.as_slice());Run

fn [next_back](../../std/iter/trait.DoubleEndedIterator.html#tymethod.next%5Fback)(&mut self) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[&'a ](../primitive.reference.html)T>[src]

Removes and returns an element from the end of the iterator. Read more

`fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where

F: FnMut(B, <Iter<'a, T> as Iterator>::Item) -> R,
R: Try<Ok = B>,
Iter<'a, T>: Sized, `[src]

🔬 This is a nightly-only experimental API. (iterator_try_fold #45594)

This is the reverse version of [try_fold()]: it takes elements starting from the back of the iterator. Read more

`fn rfold<Acc, Fold>(self, init: Acc, f: Fold) -> Acc where

Fold: FnMut(Acc, <Iter<'a, T> as Iterator>::Item) -> Acc, `[src]

🔬 This is a nightly-only experimental API. (iter_rfold #44705)

An iterator method that reduces the iterator's elements to a single, final value, starting from the back. Read more

`fn rfind

(&mut self, predicate: P) -> Option<Self::Item> where

P: FnMut(&Self::Item) -> bool, `[src]

🔬 This is a nightly-only experimental API. (iter_rfind #39480)

Searches for an element of an iterator from the right that satisfies a predicate. Read more

type [Item](../../std/iter/trait.Iterator.html#associatedtype.Item) = [&'a ](../primitive.reference.html)T

The type of the elements being iterated over.

fn [next](../../std/iter/trait.Iterator.html#tymethod.next)(&mut self) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[&'a ](../primitive.reference.html)T>[src]

Advances the iterator and returns the next value. Read more

fn [size_hint](../../std/iter/trait.Iterator.html#method.size%5Fhint)(&self) -> [(](../primitive.tuple.html)[usize](../primitive.usize.html), [Option](../../std/option/enum.Option.html "enum std::option::Option")<[usize](../primitive.usize.html)>[)](../primitive.tuple.html)[src]

Returns the bounds on the remaining length of the iterator. Read more

fn [count](../../std/iter/trait.Iterator.html#method.count)(self) -> [usize](../primitive.usize.html)[src]

Consumes the iterator, counting the number of iterations and returning it. Read more

fn [nth](../../std/iter/trait.Iterator.html#method.nth)(&mut self, n: [usize](../primitive.usize.html)) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[&'a ](../primitive.reference.html)T>[src]

Returns the nth element of the iterator. Read more

fn [last](../../std/iter/trait.Iterator.html#method.last)(self) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[&'a ](../primitive.reference.html)T>[src]

Consumes the iterator, returning the last element. Read more

`fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where

F: FnMut(B, <Iter<'a, T> as Iterator>::Item) -> R,
R: Try<Ok = B>,
Iter<'a, T>: Sized, `[src]

🔬 This is a nightly-only experimental API. (iterator_try_fold #45594)

An iterator method that applies a function as long as it returns successfully, producing a single, final value. Read more

`fn fold<Acc, Fold>(self, init: Acc, f: Fold) -> Acc where

Fold: FnMut(Acc, <Iter<'a, T> as Iterator>::Item) -> Acc, `[src]

An iterator method that applies a function, producing a single, final value. Read more

`fn position

(&mut self, predicate: P) -> Option<usize> where

P: FnMut(<Iter<'a, T> as Iterator>::Item) -> bool,
Iter<'a, T>: Sized, `[src]

Searches for an element in an iterator, returning its index. Read more

`fn rposition

(&mut self, predicate: P) -> Option<usize> where

P: FnMut(<Iter<'a, T> as Iterator>::Item) -> bool,
Iter<'a, T>: Sized,
Iter<'a, T>: ExactSizeIterator,
Iter<'a, T>: DoubleEndedIterator, `[src]

Searches for an element in an iterator from the right, returning its index. Read more

ⓘImportant traits for StepBy

fn [step_by](../../std/iter/trait.Iterator.html#method.step%5Fby)(self, step: [usize](../primitive.usize.html)) -> [StepBy](../../std/iter/struct.StepBy.html "struct std::iter::StepBy")<Self>[src]

🔬 This is a nightly-only experimental API. (iterator_step_by #27741)

unstable replacement of Range::step_by

Creates an iterator starting at the same point, but stepping by the given amount at each iteration. Read more

ⓘImportant traits for Chain<A, B>

fn [chain](../../std/iter/trait.Iterator.html#method.chain)<U>(self, other: U) -> [Chain](../../std/iter/struct.Chain.html "struct std::iter::Chain")<Self, <U as [IntoIterator](../../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator")>::[IntoIter](../../std/iter/trait.IntoIterator.html#associatedtype.IntoIter "type std::iter::IntoIterator::IntoIter")> where U: [IntoIterator](../../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator")<Item = Self::[Item](../../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")>, [src]

Takes two iterators and creates a new iterator over both in sequence. Read more

ⓘImportant traits for Zip<A, B>

fn [zip](../../std/iter/trait.Iterator.html#method.zip)<U>(self, other: U) -> [Zip](../../std/iter/struct.Zip.html "struct std::iter::Zip")<Self, <U as [IntoIterator](../../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator")>::[IntoIter](../../std/iter/trait.IntoIterator.html#associatedtype.IntoIter "type std::iter::IntoIterator::IntoIter")> where U: [IntoIterator](../../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator"), [src]

'Zips up' two iterators into a single iterator of pairs. Read more

ⓘImportant traits for Map<I, F>

fn [map](../../std/iter/trait.Iterator.html#method.map)<B, F>(self, f: F) -> [Map](../../std/iter/struct.Map.html "struct std::iter::Map")<Self, F> where F: [FnMut](../../std/ops/trait.FnMut.html "trait std::ops::FnMut")(Self::[Item](../../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> B, [src]

Takes a closure and creates an iterator which calls that closure on each element. Read more

`fn for_each(self, f: F) where

F: FnMut(Self::Item), `

1.21.0

[src]

Calls a closure on each element of an iterator. Read more

ⓘImportant traits for Filter<I, P>

fn [filter](../../std/iter/trait.Iterator.html#method.filter)<P>(self, predicate: P) -> [Filter](../../std/iter/struct.Filter.html "struct std::iter::Filter")<Self, P> where P: [FnMut](../../std/ops/trait.FnMut.html "trait std::ops::FnMut")(&Self::[Item](../../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> [bool](../primitive.bool.html), [src]

Creates an iterator which uses a closure to determine if an element should be yielded. Read more

`fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where

F: FnMut(Self::Item) -> Option, `[src]

Creates an iterator that both filters and maps. Read more

fn [enumerate](../../std/iter/trait.Iterator.html#method.enumerate)(self) -> [Enumerate](../../std/iter/struct.Enumerate.html "struct std::iter::Enumerate")<Self>[src]

Creates an iterator which gives the current iteration count as well as the next value. Read more

fn [peekable](../../std/iter/trait.Iterator.html#method.peekable)(self) -> [Peekable](../../std/iter/struct.Peekable.html "struct std::iter::Peekable")<Self>[src]

Creates an iterator which can use peek to look at the next element of the iterator without consuming it. Read more

`fn skip_while

(self, predicate: P) -> SkipWhile<Self, P> where

P: FnMut(&Self::Item) -> bool, `[src]

Creates an iterator that [skip]s elements based on a predicate. Read more

`fn take_while

(self, predicate: P) -> TakeWhile<Self, P> where

P: FnMut(&Self::Item) -> bool, `[src]

Creates an iterator that yields elements based on a predicate. Read more

ⓘImportant traits for Skip

fn [skip](../../std/iter/trait.Iterator.html#method.skip)(self, n: [usize](../primitive.usize.html)) -> [Skip](../../std/iter/struct.Skip.html "struct std::iter::Skip")<Self>[src]

Creates an iterator that skips the first n elements. Read more

ⓘImportant traits for Take

fn [take](../../std/iter/trait.Iterator.html#method.take)(self, n: [usize](../primitive.usize.html)) -> [Take](../../std/iter/struct.Take.html "struct std::iter::Take")<Self>[src]

Creates an iterator that yields its first n elements. Read more

ⓘImportant traits for Scan<I, St, F>

Important traits for Scan<I, St, F>

impl<B, I, St, F> [Iterator](../../std/iter/trait.Iterator.html "trait std::iter::Iterator") for [Scan](../../std/iter/struct.Scan.html "struct std::iter::Scan")<I, St, F> where F: [FnMut](../../std/ops/trait.FnMut.html "trait std::ops::FnMut")([&mut ](../primitive.reference.html)St, <I as [Iterator](../../std/iter/trait.Iterator.html "trait std::iter::Iterator")>::[Item](../../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<B>, I: [Iterator](../../std/iter/trait.Iterator.html "trait std::iter::Iterator"), type [Item](../../std/iter/trait.Iterator.html#associatedtype.Item) = B;

fn [scan](../../std/iter/trait.Iterator.html#method.scan)<St, B, F>(self, initial_state: St, f: F) -> [Scan](../../std/iter/struct.Scan.html "struct std::iter::Scan")<Self, St, F> where F: [FnMut](../../std/ops/trait.FnMut.html "trait std::ops::FnMut")([&mut ](../primitive.reference.html)St, Self::[Item](../../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<B>, [src]

An iterator adaptor similar to [fold] that holds internal state and produces a new iterator. Read more

ⓘImportant traits for FlatMap<I, U, F>

fn [flat_map](../../std/iter/trait.Iterator.html#method.flat%5Fmap)<U, F>(self, f: F) -> [FlatMap](../../std/iter/struct.FlatMap.html "struct std::iter::FlatMap")<Self, U, F> where F: [FnMut](../../std/ops/trait.FnMut.html "trait std::ops::FnMut")(Self::[Item](../../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> U, U: [IntoIterator](../../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator"), [src]

Creates an iterator that works like map, but flattens nested structure. Read more

ⓘImportant traits for Fuse

fn [fuse](../../std/iter/trait.Iterator.html#method.fuse)(self) -> [Fuse](../../std/iter/struct.Fuse.html "struct std::iter::Fuse")<Self>[src]

Creates an iterator which ends after the first [None]. Read more

ⓘImportant traits for Inspect<I, F>

fn [inspect](../../std/iter/trait.Iterator.html#method.inspect)<F>(self, f: F) -> [Inspect](../../std/iter/struct.Inspect.html "struct std::iter::Inspect")<Self, F> where F: [FnMut](../../std/ops/trait.FnMut.html "trait std::ops::FnMut")(&Self::[Item](../../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")), [src]

Do something with each element of an iterator, passing the value on. Read more

fn [by_ref](../../std/iter/trait.Iterator.html#method.by%5Fref)(&mut self) -> [&mut ](../primitive.reference.html)Self[src]

Borrows an iterator, rather than consuming it. Read more

`fn collect(self) -> B where

B: FromIterator<Self::Item>, `[src]

Transforms an iterator into a collection. Read more

`fn partition<B, F>(self, f: F) -> (B, B) where

B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool, `[src]

Consumes an iterator, creating two collections from it. Read more

`fn all(&mut self, f: F) -> bool where

F: FnMut(Self::Item) -> bool, `[src]

Tests if every element of the iterator matches a predicate. Read more

`fn any(&mut self, f: F) -> bool where

F: FnMut(Self::Item) -> bool, `[src]

Tests if any element of the iterator matches a predicate. Read more

`fn find

(&mut self, predicate: P) -> Option<Self::Item> where

P: FnMut(&Self::Item) -> bool, `[src]

Searches for an element of an iterator that satisfies a predicate. Read more

`fn max(self) -> Option<Self::Item> where

Self::Item: Ord, `[src]

Returns the maximum element of an iterator. Read more

`fn min(self) -> Option<Self::Item> where

Self::Item: Ord, `[src]

Returns the minimum element of an iterator. Read more

`fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where

B: Ord,
F: FnMut(&Self::Item) -> B, `

1.6.0

[src]

Returns the element that gives the maximum value from the specified function. Read more

`fn max_by(self, compare: F) -> Option<Self::Item> where

F: FnMut(&Self::Item, &Self::Item) -> Ordering, `

1.15.0

[src]

Returns the element that gives the maximum value with respect to the specified comparison function. Read more

`fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where

B: Ord,
F: FnMut(&Self::Item) -> B, `

1.6.0

[src]

Returns the element that gives the minimum value from the specified function. Read more

`fn min_by(self, compare: F) -> Option<Self::Item> where

F: FnMut(&Self::Item, &Self::Item) -> Ordering, `

1.15.0

[src]

Returns the element that gives the minimum value with respect to the specified comparison function. Read more

ⓘImportant traits for Rev

fn [rev](../../std/iter/trait.Iterator.html#method.rev)(self) -> [Rev](../../std/iter/struct.Rev.html "struct std::iter::Rev")<Self> where Self: [DoubleEndedIterator](../../std/iter/trait.DoubleEndedIterator.html "trait std::iter::DoubleEndedIterator"), [src]

Reverses an iterator's direction. Read more

`fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where

FromA: Default + Extend,
FromB:
Default + Extend,
Self: Iterator<Item = (A, B)>, `[src]

Converts an iterator of pairs into a pair of containers. Read more

ⓘImportant traits for Cloned

fn [cloned](../../std/iter/trait.Iterator.html#method.cloned)<'a, T>(self) -> [Cloned](../../std/iter/struct.Cloned.html "struct std::iter::Cloned")<Self> where Self: [Iterator](../../std/iter/trait.Iterator.html "trait std::iter::Iterator")<Item = [&'a ](../primitive.reference.html)T>, T: 'a + [Clone](../../std/clone/trait.Clone.html "trait std::clone::Clone"), [src]

Creates an iterator which [clone]s all of its elements. Read more

ⓘImportant traits for Cycle

fn [cycle](../../std/iter/trait.Iterator.html#method.cycle)(self) -> [Cycle](../../std/iter/struct.Cycle.html "struct std::iter::Cycle")<Self> where Self: [Clone](../../std/clone/trait.Clone.html "trait std::clone::Clone"), [src]

Repeats an iterator endlessly. Read more

`fn sum(self) -> S where

S: Sum<Self::Item>, `

1.11.0

[src]

Sums the elements of an iterator. Read more

`fn product

(self) -> P where

P: Product<Self::Item>, `

1.11.0

[src]

Iterates over the entire iterator, multiplying all the elements Read more

`fn cmp(self, other: I) -> Ordering where

I: IntoIterator<Item = Self::Item>,
Self::Item: Ord, `

1.5.0

[src]

Lexicographically compares the elements of this Iterator with those of another. Read more

`fn partial_cmp(self, other: I) -> Option<Ordering> where

I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `

1.5.0

[src]

Lexicographically compares the elements of this Iterator with those of another. Read more

`fn eq(self, other: I) -> bool where

I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>, `

1.5.0

[src]

Determines if the elements of this Iterator are equal to those of another. Read more

`fn ne(self, other: I) -> bool where

I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>, `

1.5.0

[src]

Determines if the elements of this Iterator are unequal to those of another. Read more

`fn lt(self, other: I) -> bool where

I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `

1.5.0

[src]

Determines if the elements of this Iterator are lexicographically less than those of another. Read more

`fn le(self, other: I) -> bool where

I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `

1.5.0

[src]

Determines if the elements of this Iterator are lexicographically less or equal to those of another. Read more

`fn gt(self, other: I) -> bool where

I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `

1.5.0

[src]

Determines if the elements of this Iterator are lexicographically greater than those of another. Read more

`fn ge(self, other: I) -> bool where

I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `

1.5.0

[src]

Determines if the elements of this Iterator are lexicographically greater than or equal to those of another. Read more