> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
> Use this file to discover all available pages before exploring further.

# core::iter::adapters::peekable::PeekableTrait

## Signature

```rust theme={null}
pub trait PeekableTrait+Copy+Drop>
```

## Trait functions

### peek

Returns a copy of the next() value without advancing the iterator.
Like `next`, if there is a value, it is wrapped in a `Some(T)`.
But if the iteration is over, `None` is returned.

#### Signature

```rust theme={null}
fn peek,
    +Copy,
    +Drop,
    I,
    impl IterI: Iterator,
    +Copy,
    +Drop,
>(
    ref self: Peekable,
) -> Option
```

#### Examples

Basic usage:

```rust theme={null}
let mut iter = (1..4_u8).into_iter().peekable();

// peek() lets us see one step into the future
assert_eq!(iter.peek(), Some(1));
assert_eq!(iter.next(), Some(1));

assert_eq!(iter.next(), Some(2));

// The iterator does not advance even if we `peek` multiple times
assert_eq!(iter.peek(), Some(3));
assert_eq!(iter.peek(), Some(3));

assert_eq!(iter.next(), Some(3));

// After the iterator is finished, so is `peek()`
assert_eq!(iter.peek(), None);
assert_eq!(iter.next(), None);
```
