std::iter::TrustedLen - Rust
Description: API documentation for the Rust `TrustedLen` trait in crate `std`.
Keywords: rust, rustlang, rust-lang, TrustedLen

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

    pub unsafe trait TrustedLen: Iterator { }

Unstable (`trusted_len` #37572)

An iterator that reports an accurate length using size_hint.

The iterator reports a size hint where it is either exact (lower bound is equal to upper bound), or the upper bound is `None`. The upper bound must only be `None` if the actual iterator length is larger than `usize::MAX`.

The iterator must produce exactly the number of elements it reported.

# Safety

This trait must only be implemented when the contract is upheld. Consumers of this trait must inspect `.size_hint()`’s upper bound.

## Implementors

- `impl<'a, I> TrustedLen for &'a mut I where I: TrustedLen + ?Sized`
- `impl<I> TrustedLen for Rev<I> where I: TrustedLen + DoubleEndedIterator`
- `impl<'a, I, T> TrustedLen for Cloned<I> where I: TrustedLen<Item=&'a T>, T: 'a + Clone`
- `impl<A, B> TrustedLen for Chain<A, B> where A: TrustedLen, B: TrustedLen<Item=A::Item>`
- `impl<A, B> TrustedLen for Zip<A, B> where A: TrustedLen, B: TrustedLen`
- `impl<B, I, F> TrustedLen for Map<I, F> where F: FnMut(I::Item) -> B, I: TrustedLen`
- `impl<I> TrustedLen for Enumerate<I> where I: TrustedLen`
- `impl<'a, A> TrustedLen for Iter<'a, A>`
- `impl<'a, A> TrustedLen for IterMut<'a, A>`
- `impl<A> TrustedLen for IntoIter<A>`
- `impl<'a, A> TrustedLen for Iter<'a, A>`
- `impl<'a, A> TrustedLen for IterMut<'a, A>`
- `impl<A> TrustedLen for IntoIter<A>`
- `impl<'a, T> TrustedLen for Iter<'a, T>`
- `impl<'a, T> TrustedLen for IterMut<'a, T>`
- `impl TrustedLen for Range<usize>`
- `impl TrustedLen for Range<isize>`
- `impl TrustedLen for Range<u8>`
- `impl TrustedLen for Range<i8>`
- `impl TrustedLen for Range<u16>`
- `impl TrustedLen for Range<i16>`
- `impl TrustedLen for Range<u32>`
- `impl TrustedLen for Range<i32>`
- `impl TrustedLen for Range<i64>`
- `impl TrustedLen for Range<u64>`
- `impl TrustedLen for RangeInclusive<usize>`
- `impl TrustedLen for RangeInclusive<isize>`
- `impl TrustedLen for RangeInclusive<u8>`
- `impl TrustedLen for RangeInclusive<i8>`
- `impl TrustedLen for RangeInclusive<u16>`
- `impl TrustedLen for RangeInclusive<i16>`
- `impl TrustedLen for RangeInclusive<u32>`
- `impl TrustedLen for RangeInclusive<i32>`
- `impl TrustedLen for RangeInclusive<i64>`
- `impl TrustedLen for RangeInclusive<u64>`
- `impl<T> TrustedLen for IntoIter<T>`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)