---
title: AnyIterator
framework: swift
role: symbol
role_heading: Structure
path: swift/anyiterator
---

# AnyIterator

A type-erased iterator of Element.

## Declaration

```swift
@frozen struct AnyIterator<Element>
```

## Overview

Overview This iterator forwards its next() method to an arbitrary underlying iterator having the same Element type, hiding the specifics of the underlying IteratorProtocol.

## Topics

### Initializers

- [init(_:)](swift/anyiterator/init(_:)-3m1u6.md)
- [init(_:)](swift/anyiterator/init(_:)-5l6js.md)

### Default Implementations

- [IteratorProtocol Implementations](swift/anyiterator/iteratorprotocol-implementations.md)
- [Sequence Implementations](swift/anyiterator/sequence-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [Escapable](swift/escapable.md)
- [IteratorProtocol](swift/iteratorprotocol.md)
- [Sequence](swift/sequence.md)

## See Also

### Type-Erasing Wrappers

- [AnySequence](swift/anysequence.md)
- [AnyCollection](swift/anycollection.md)
- [AnyBidirectionalCollection](swift/anybidirectionalcollection.md)
- [AnyRandomAccessCollection](swift/anyrandomaccesscollection.md)
- [AnyIndex](swift/anyindex.md)
- [AnyHashable](swift/anyhashable.md)
