class_name VariantIterator extends Iterator

var _iterable: Variant
var _state: Array

func _init(value) -> void:
    _iterable = value
    _state = value._iter_init([])

func clone() -> VariantIterator:
    var new = VariantIterator.new(_iterable)
    new._state = _state
    return new

func next() -> Option:
    if _iterable._iter_next(_state):
        return Option.some(_iterable._iter_get(_state[0]))
    else: return Option.none
