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

    pub unsafe trait TrustedLen: Iterator { }

🔬 This is a nightly-only experimental API. (`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`. In that case, the lower bound must be `usize::MAX`, resulting in a `.size_hint` of `(usize::MAX, None)`.

The iterator must produce exactly the number of elements it reported or diverge before reaching the end.

# 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 TrustedLen for Range<usize>` | [src]

- `impl TrustedLen for Range<isize>` | [src]

- `impl TrustedLen for Range<u8>` | [src]

- `impl TrustedLen for Range<i8>` | [src]

- `impl TrustedLen for Range<u16>` | [src]

- `impl TrustedLen for Range<i16>` | [src]

- `impl TrustedLen for Range<u32>` | [src]

- `impl TrustedLen for Range<i32>` | [src]

- `impl TrustedLen for Range<i64>` | [src]

- `impl TrustedLen for Range<u64>` | [src]

- `impl TrustedLen for RangeInclusive<usize>` | [src]

- `impl TrustedLen for RangeInclusive<isize>` | [src]

- `impl TrustedLen for RangeInclusive<u8>` | [src]

- `impl TrustedLen for RangeInclusive<i8>` | [src]

- `impl TrustedLen for RangeInclusive<u16>` | [src]

- `impl TrustedLen for RangeInclusive<i16>` | [src]

- `impl TrustedLen for RangeInclusive<u32>` | [src]

- `impl TrustedLen for RangeInclusive<i32>` | [src]

- `impl TrustedLen for RangeInclusive<i64>` | [src]

- `impl TrustedLen for RangeInclusive<u64>` | [src]

- `impl<A: Step> TrustedLen for RangeFrom<A>` | [src]

- `impl<A: Clone> TrustedLen for Repeat<A>` | [src]

- `impl<A, F: FnMut() -> A> TrustedLen for RepeatWith<F>` | [src]

- `impl<T> TrustedLen for Empty<T>` | [src]

- `impl<T> TrustedLen for Once<T>` | [src]

- `impl<'a, I: TrustedLen + ?Sized> TrustedLen for &'a mut I` | [src]

- `impl<I> TrustedLen for Rev<I> where I: TrustedLen + DoubleEndedIterator,` | [src]

- `impl<'a, I, T: 'a> TrustedLen for Cloned<I> where I: TrustedLen<Item = &'a T>, T: Clone,` | [src]

- `impl<A, B> TrustedLen for Chain<A, B> where A: TrustedLen, B: TrustedLen<Item = A::Item>,` | [src]

- `impl<A, B> TrustedLen for Zip<A, B> where A: TrustedLen, B: TrustedLen,` | [src]

- `impl<B, I, F> TrustedLen for Map<I, F> where I: TrustedLen, F: FnMut(I::Item) -> B,` | [src]

- `impl<I> TrustedLen for Enumerate<I> where I: TrustedLen,` | [src]

- `impl<I: TrustedLen> TrustedLen for Take<I>` | [src]

- `impl<'a, A> TrustedLen for core::option::Iter<'a, A>` | [src]

- `impl<'a, A> TrustedLen for core::option::IterMut<'a, A>` | [src]

- `impl<A> TrustedLen for core::option::IntoIter<A>` | [src]

- `impl<'a, A> TrustedLen for core::result::Iter<'a, A>` | [src]

- `impl<'a, A> TrustedLen for core::result::IterMut<'a, A>` | [src]

- `impl<A> TrustedLen for core::result::IntoIter<A>` | [src]

- `impl<'a, T> TrustedLen for core::slice::Iter<'a, T>` | [src]

- `impl<'a, T> TrustedLen for core::slice::IterMut<'a, T>` | [src]

- `impl<'a> TrustedLen for Bytes<'a>` | [src]

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse 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`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)